Hi,
I am working on small turn-based game and now thinking about some easy way to animate objects. What I want to achive is to let for example player character to animate from one tile to other (so if I press RIGHT key, it will not only jump eg. 32 pixels to the right but slowly slide there with animation). Something like in dungeons of dremor but not so fancy of course:
I know how to run animation but don’t know how to fit it in the turn-based model. I do something like this in my hero class:
public void act() {
if (control.action == Actions.RIGHT) {
hero1.setCurrentFrame(frame); //hero1 is instance of Animation
x=x+32;
frame ^= 1; // switch between two frames
Then render() and update() methods do just following:
public void render(GameContainer container, StateBasedGame game, Graphics g)
throws SlickException {
hero.hero1.draw(hero.x, hero.y);
}
@Override
public void update(GameContainer container, StateBasedGame game, int delta)
throws SlickException {
hero.act();
I would normaly put this slide/animation code to update/render methods but it does not seem to be a good idea with my turn-based design (need to keep track if player’s instance already played and/or can play again, etc.).
Is there some way to render animation outside the GameState’s render() method? I tried to call hero1.draw(x,y) method in a loop in my hero’s class but it did not draw anything at all.
Thank you…hope my question is clear.