I'm pretty far down the road in my game right now, closing in on the end. And I'm adding little tweaks here and there. I used custom frame animation of a single image with many versions of my sprite on it, and controlled which part of the image to show using rectangles. But I'm starting to think that maybe I should've used the Animation API that comes with android instead.
Will this effect my performance in a negative way?
Can I still use rectangles to draw my bitmap?
Could I add effects from the Animation API to my current frame-controlled animation? like the fadeout-effect etc? this would mean I wont have to change my current code.
I want some of my animations to fade out, and just noticed that using the Animation API makes things alot easier. But needless to say, I would prefer not having to change all my animation-code.
I'm bad at explaining, so Ill show a bit of how I do my animation:
private static final int BMP_ROWS = 1; //I use top-view so only need my sprite to have 1 direction
private static final int BMP_COLUMNS = 3;
public void update(GameControls controls) {
if (sprite.isMoving) {
currentFrame = ++currentFrame % BMP_COLUMNS;
} else {
this.setFrame(1);
}
}
public void draw(Canvas canvas, int x, int y, float angle) {
this.x=x;
this.y=y;
canvas.save();
canvas.rotate(angle , x + width / 2, y + height / 2);
int srcX = currentFrame * width;
int srcY = 0 * height;
Rect src = new Rect(srcX, srcY, srcX + width, srcY + height);
Rect dst = new Rect(x, y, x + width, y + height);
canvas.drawBitmap(bitmap, src, dst, null);
canvas.restore();
}