コード例 #1
0
 public void onStep() {
   super.onStep();
   float rXOld = rX;
   float rYOld = rY;
   rX = rX - Math.signum(rX) * Game.getDeltaSeconds() * 250;
   rY = rY - Math.signum(rY) * Game.getDeltaSeconds() * 250;
   if (rXOld * rX < 0 || rYOld * rY < 0 || (rXOld == rX && rYOld == rY)) {
     rX = 0;
     rY = 0;
     if (path != null) {
       if (path.size() == 0) {
         // We made it to destination
         path = null;
         callback.execute();
       } else {
         Node next = path.removeFirst();
         rX = -(next.x - xcoord) * 16;
         rY = -(next.y - ycoord) * 16;
         xcoord = next.x;
         ycoord = next.y;
         x = xcoord * 16;
         y = ycoord * 16;
       }
     }
   }
 }
コード例 #2
0
 public void beginStep() {
   super.beginStep();
   if (Game.glContextExists() && !sprite.hasAnimation("IDLE")) {
     loadMapSprites();
   }
   if (path != null) {
     String name;
     if (rX > 0) name = "left";
     else if (rX < 0) name = "right";
     else if (rY > 0) name = "up";
     else name = "down";
     sprite.setAnimation(name);
   }
   renderDepth = calcRenderDepth();
 }