Beispiel #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;
       }
     }
   }
 }