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; } }
public void animate(int frame) { currentFrame = frame; spriteRect.top = ((frame) / hFrames) * spriteHeight; spriteRect.bottom = spriteHeight; spriteRect.left = ((frame) % hFrames) * spriteWidth; spriteRect.right = spriteWidth; }
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; }
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; }
public void resetDest() { destRect.top = 0; destRect.bottom = 0; destRect.left = 0; destRect.right = 0; }
public void flip() { int oldTop = spriteRect.top; spriteRect.top = spriteRect.bottom; spriteRect.bottom = oldTop; }
public void updateSprite(int x1, int y1, int x2, int y2) { spriteRect.top = y1; spriteRect.right = x2; spriteRect.bottom = y2; spriteRect.left = x1; }