当前位置: 首页>>代码示例>>Java>>正文


Java Spatial.move方法代码示例

本文整理汇总了Java中com.jme3.scene.Spatial.move方法的典型用法代码示例。如果您正苦于以下问题:Java Spatial.move方法的具体用法?Java Spatial.move怎么用?Java Spatial.move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.scene.Spatial的用法示例。


在下文中一共展示了Spatial.move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: positionPlayers

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Position all of the players to their start positions. Players placed on an XY plane in front of the first course
 * point. Fill columns first and then add new rows.
 * @param players Array of all players in game.
 */
private void positionPlayers(Spatial[] players) {
  // There must be a starting course point.
  Spatial[] coursePoints = coursePath.getCoursePoints();
  if (coursePoints.length == 0) {
    return;
  }
  Spatial firstCoursePoint = coursePoints[0];

  // Players start on an X/Y plane. Determine the amount of rows and columns. Fill rows before starting new columns.
  int rows = (players.length / (MAX_COLUMNS + 1)) + 1,
      columns = Math.min(players.length, MAX_COLUMNS);
  // Determine the distance on the X axis to the furthest players.
  float xEnd = ((columns - 1) * PLAYER_START_SEPARATION) / 2,
        yEnd = ((rows - 1) * PLAYER_START_SEPARATION) / 2;

  for (int i = 0; i < players.length; ++i) {
    Spatial player = players[i];
    // X axis starts on the far left and begins placing players left to right.
    // Y axis starts on the far low point and begins placing rows from bottom to top as rows fill.
    // Z axis is a constant distance from the first course point.
    float x = (i % columns) * PLAYER_START_SEPARATION - xEnd,
          y = -(i / columns) * PLAYER_START_SEPARATION + yEnd;
    player.setLocalTransform(firstCoursePoint.getWorldTransform());
    player.move(player.getLocalRotation().mult(Vector3f.UNIT_X).mult(x));
    player.move(player.getLocalRotation().mult(Vector3f.UNIT_Y).mult(y));
    player.move(player.getLocalRotation().mult(Vector3f.UNIT_Z).mult(PLAYER_START_DISTANCE));
  }
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:34,代码来源:PlayerManager.java

示例2: update

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Update all players.
 * @param tpf Milliseconds since last frame.
 */
public void update(float tpf) {
  for (Spatial player : players) {
    // Update player character.
    Vector3f forward = player.getLocalRotation().mult(Vector3f.UNIT_Z);
    player.move(forward.mult(-PLAYER_SPEED * tpf));
  }
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:12,代码来源:PlayerManager.java


注:本文中的com.jme3.scene.Spatial.move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。