Posted April 11, 2019 by Luke Tolchard
I have now integrated the previously created sprites into our game.
If the player is moving, a variable called anim_count ticks up. The names of the sprites are named in such a way that I can read them into the function and check 2 ints to determine which is the correct image to be loaded.
AvaX-cycleY
The X value represents the level that the set of sprites is used, and the Y value represents where that image goes in the sequence. The sprite component loads the texture of the next sprite in the sequence.
If anim_count >= 5, the animation must have ended so it hard resets to 0 to begin the cycle again.
Finally, if the player is no longer grounded (Jumping or falling) the anim_count is hard set at 2, which in every sequence is a sprite where the player is in a pose similar to that of a jump. This stops to running animation playing when the character is in the air, and instead hold a pose similar to the jump pose of a Mario sprite.