🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Best Practices for Organizing a Sprite Sheet that needs to support concurrent states

Started by
1 comment, last by LorenzoGatti 5 years, 9 months ago

Hello, I'm working on developing a 2D platformer. In the game, the player can run/jump/etc, and they can also often shoot at the same time that they're performing these other actions. For programming these actions, I have no issue constructing the relevant FSMs and getting them to behave as intended. My issue comes when I need to find the right frames or animations for the sprite to show. Should the game just check if the player is shooting and what state they're in and then have the right animations hardcoded in to play in each possible outcome of that if statement? I've considered some potentially more elegant solutions like having a normal sprite sheet and then a shooting sprite sheet where the shooting sheet has the corresponding shooting frame at the same position in the sheet. Then the animator would just have to load the correct frame of its current sheet no matter what, and whenever the player is shooting, it simply swaps out the regular sprite sheet for the shooting one.

Basically I can think of a few different ideas that sort of solve this problem, but none of them seem ideal. I wanted to know what the generally accepted best practices are for this type of problem. Any advice would be appreciated.

Advertisement

From an abstract point of view, states like "shooting forward in free fall" or "jumping away from a vertical wall" are too coarse for animation: you need separate transition animations (hopefully simple, and possibly trivial) for each animation frame and each legitimate action.

For instance, if the character can shoot forward while running and also stop and turn back while running it can do both at the same time, at different frames of the relatively long direction change transition: for each of those frames you need to decide whether the character can shoot, and draw a variant of the turning animation, which will later merge with the appropriate frame of the main "running while shooting" animation in the opposite direction.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement