Hello everyone, I’m using libGDX for my current game and I’ve encountered a problem. I have an animation with 12 frames that works perfectly, changing frames every 40 milliseconds, and I have a separate sprite for the main character’s arm. The problem is, I want the arm to move up and down as the player’s animation ‘bounces’. I can’t have the arm as part of the sprite because of the nature of the game. Any help or suggestions would be wonderful, as I haven’t found anything useful through google.
What do you mean by “can’t have the arm as part of the sprite”?
Oh well let’s assume you can’t put the arms into your Animation class. Then you need a class that holds your current animation and arm sprites. On its act() check the condition and adjust the arms relatively to animation’s position.
Hope help.
The arm is a separate ‘sprite’ class that rotates based on the location of the mouse, which would make for hundreds of different player animations if I were to unite them. Currently I am trying to use the state time (time since the application opened) to judge where the arm should be (relative to the animation) but this doesn’t work, for some strange reason. Is this helpful for understanding? What I really need is a ‘return current frame as an integer’ method, so I’m not sure how to go about doing this, or if I should give up on having the arm separate.
Yap my previous solution should still apply. Basically you manage two sprite, one is animating (the body, change due to movement behavior) and one other is the arm (rotating due to mouse behavior). What you have to do are let them update themselves according each own behavior, then adjust the arm position to body sprite.
You’ll have to just position the arm based on the time you pass to the animation. You could use something like Spine, though it isn’t ready yet (link in my signature).