Пример #1
0
 public void update(float x, float y) {
   if (centered) {
     destRect.top = (int) (y - (imgHeight / 2));
     destRect.bottom = imgHeight;
     destRect.left = (int) (x - (imgWidth / 2));
     destRect.right = imgWidth;
   } else {
     destRect.top = (int) y;
     destRect.bottom = imgHeight;
     destRect.left = (int) x;
     destRect.right = imgWidth;
   }
 }
Пример #2
0
 public void animate(int frame) {
   currentFrame = frame;
   spriteRect.top = ((frame) / hFrames) * spriteHeight;
   spriteRect.bottom = spriteHeight;
   spriteRect.left = ((frame) % hFrames) * spriteWidth;
   spriteRect.right = spriteWidth;
 }
Пример #3
0
 public boolean animate() {
   finished = false;
   if (currentFrame + rate < frames) {
     currentFrame += rate;
   } else {
     finished = true;
     currentFrame = 0;
   }
   spriteRect.top = (((int) currentFrame) / hFrames) * spriteHeight;
   spriteRect.bottom = spriteHeight;
   spriteRect.left = (((int) currentFrame) % hFrames) * spriteWidth;
   spriteRect.right = spriteWidth;
   return finished;
 }
Пример #4
0
 public void animate(int start, int end, float mod) {
   end++;
   if (currentFrame < start) {
     currentFrame = start;
   }
   if (currentFrame + (rate * mod) < end - 1) currentFrame += (rate * mod);
   else {
     finished = true;
     currentFrame = start;
   }
   spriteRect.top = (((int) currentFrame) / hFrames) * spriteHeight;
   spriteRect.bottom = spriteHeight;
   spriteRect.left = (((int) currentFrame) % hFrames) * spriteWidth;
   spriteRect.right = spriteWidth;
 }
Пример #5
0
 public void resetDest() {
   destRect.top = 0;
   destRect.bottom = 0;
   destRect.left = 0;
   destRect.right = 0;
 }
Пример #6
0
 public void flip() {
   int oldTop = spriteRect.top;
   spriteRect.top = spriteRect.bottom;
   spriteRect.bottom = oldTop;
 }
Пример #7
0
 public void updateSprite(int x1, int y1, int x2, int y2) {
   spriteRect.top = y1;
   spriteRect.right = x2;
   spriteRect.bottom = y2;
   spriteRect.left = x1;
 }