0
votes

Could anybody give any tip about how a running and shooting animation for a sprite is done? I mean, how to sincronize it with the running animation to make the transition running -> running + fire -> running smooth without glitches.

I have been studying a bit metal slug. This game has a walk animation, and a walk + shoot animation and it is really smooth. Could it be they have legs and body separated?.

Thanks in advance.

1

1 Answers

1
votes

The way I would implement it is have an array of images containing the walking animation, and an equally large array containing the walking + shooting animation, and then keeping track of the state with an enum (e.g. WALKING and SHOOTING).

That's assuming the difference between sheathed and unsheathed weapon is quite small in terms of distance. Optionally the setState-method in your animation-class could queue a third array of images where the weapon is being brought into position.

STATE(image index)
WALKING(1) -> setState(SHOOTING) -> TRANSITION(2) -> SHOOTING(3) -> SHOOTING(4)
etc

The additional transition-array just adds complexity and can often be omitted since the distance usually isn't that large.