當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。