本文整理汇总了Java中com.badlogic.gdx.ai.utils.Location.newLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Location.newLocation方法的具体用法?Java Location.newLocation怎么用?Java Location.newLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.ai.utils.Location
的用法示例。
在下文中一共展示了Location.newLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateDriftOffset
import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
/** Calculates the drift offset when members are in the given set of slots for the specified pattern.
* @param centerOfMass the output location set to the calculated drift offset
* @param slotAssignments the set of slots
* @param pattern the pattern
* @return the given location for chaining. */
public Location<T> calculateDriftOffset (Location<T> centerOfMass, Array<SlotAssignment<T>> slotAssignments,
FormationPattern<T> pattern) {
// Clear the center of mass
centerOfMass.getPosition().setZero();
float centerOfMassOrientation = 0;
// Make sure tempLocation is instantiated
if (tempLocation == null) tempLocation = centerOfMass.newLocation();
T centerOfMassPos = centerOfMass.getPosition();
T tempLocationPos = tempLocation.getPosition();
// Go through each assignment and add its contribution to the center
float numberOfAssignments = slotAssignments.size;
for (int i = 0; i < numberOfAssignments; i++) {
pattern.calculateSlotLocation(tempLocation, slotAssignments.get(i).slotNumber);
centerOfMassPos.add(tempLocationPos);
centerOfMassOrientation += tempLocation.getOrientation();
}
// Divide through to get the drift offset.
centerOfMassPos.scl(1f / numberOfAssignments);
centerOfMassOrientation /= numberOfAssignments;
centerOfMass.setOrientation(centerOfMassOrientation);
return centerOfMass;
}
示例2: Formation
import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
/** Creates a {@code Formation} for the specified {@code pattern}, {@code slotAssignmentStrategy} and {@code moderator}.
* @param anchor the anchor point of this formation, usually a {@link Steerable}. Cannot be {@code null}.
* @param pattern the pattern of this formation
* @param slotAssignmentStrategy the strategy used to assign a member to his slot
* @param motionModerator the motion moderator. Can be {@code null} if moderation is not needed
* @throws IllegalArgumentException if the anchor point is {@code null} */
public Formation (Location<T> anchor, FormationPattern<T> pattern, SlotAssignmentStrategy<T> slotAssignmentStrategy,
FormationMotionModerator<T> motionModerator) {
if (anchor == null) throw new IllegalArgumentException("The anchor point cannot be null");
this.anchor = anchor;
this.pattern = pattern;
this.slotAssignmentStrategy = slotAssignmentStrategy;
this.motionModerator = motionModerator;
this.slotAssignments = new Array<SlotAssignment<T>>();
this.driftOffset = anchor.newLocation();
this.positionOffset = anchor.getPosition().cpy();
}