Beispiel #1
0
 public void animate(int frame) {
   currentFrame = frame;
   spriteRect.top = ((frame) / hFrames) * spriteHeight;
   spriteRect.bottom = spriteHeight;
   spriteRect.left = ((frame) % hFrames) * spriteWidth;
   spriteRect.right = spriteWidth;
 }
Beispiel #2
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;
 }
Beispiel #3
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;
 }
Beispiel #4
0
 public void updateLayout(int vFrames, int hFrames) {
   if (vFrames < 1) {
     vFrames = 1;
   } else if (vFrames > 99) {
     vFrames = 99;
   }
   if (hFrames < 1) {
     hFrames = 1;
   } else if (hFrames > 99) {
     hFrames = 99;
   }
   this.hFrames = hFrames;
   this.vFrames = vFrames;
   spriteWidth = imgWidth = image.getWidth() / this.hFrames;
   spriteHeight = imgHeight = image.getHeight() / this.vFrames;
   frames = (hFrames * vFrames);
   spriteRect.right = spriteWidth;
   spriteRect.bottom = spriteHeight;
 }
Beispiel #5
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;
   }
 }
Beispiel #6
0
 public void resetDest() {
   destRect.top = 0;
   destRect.bottom = 0;
   destRect.left = 0;
   destRect.right = 0;
 }
Beispiel #7
0
 public void flip() {
   int oldTop = spriteRect.top;
   spriteRect.top = spriteRect.bottom;
   spriteRect.bottom = oldTop;
 }
Beispiel #8
0
 public void reflect() {
   int oldLeft = spriteRect.left;
   spriteRect.left = spriteRect.right;
   spriteRect.right = oldLeft;
 }
Beispiel #9
0
 public void updateSprite(int x1, int y1, int x2, int y2) {
   spriteRect.top = y1;
   spriteRect.right = x2;
   spriteRect.bottom = y2;
   spriteRect.left = x1;
 }