Skip to content

TurnBasedRPG: Incorrect walking animations #284

Open
@Poobslag

Description

@Poobslag

During the 4 - Sprites and Animation section of the TurnBasedRPG tutorial, there is some conflicting advice given:

Now, we need to define our animations. In our case, we want each animation to end with the player in their 'neutral' pose (legs together), that way each time we animate the player, it will return to the correct frame as soon as they stop animating. So, add:

animation.add("lr", [3, 4, 3, 5], 6, false);
animation.add("u", [6, 7, 6, 8], 6, false);
animation.add("d", [0, 1, 0, 2], 6, false);

This advice implies that these animations will end with the player in their 'neutral' pose. However, visual examination of the player.png image referenced by the tutorial reveals that the neutral animation frames are frames 0, 3 and 6 -- not 5, 8 and 2. This can also be demonstrated by playing the HTML5 TurnBasedRPG in a browser (https://haxeflixel.com/demos/TurnBasedRPG/). After moving the player, they end their animation with one leg sticking out.

This can be corrected by applying the following diff, which moves the first frame in the animation to the end:

diff --git a/Tutorials/TurnBasedRPG/source/Player.hx b/Tutorials/TurnBasedRPG/source/Player.hx
index 567727e3..801a321d 100644
--- a/Tutorials/TurnBasedRPG/source/Player.hx
+++ b/Tutorials/TurnBasedRPG/source/Player.hx
@@ -18,9 +18,9 @@ class Player extends FlxSprite
                loadGraphic(AssetPaths.player__png, true, 16, 16);
                setFacingFlip(FlxObject.LEFT, false, false);
                setFacingFlip(FlxObject.RIGHT, true, false);
-               animation.add("lr", [3, 4, 3, 5], 6, false);
-               animation.add("u", [6, 7, 6, 8], 6, false);
-               animation.add("d", [0, 1, 0, 2], 6, false);
+               animation.add("lr", [4, 3, 5, 3], 6, false);
+               animation.add("u", [7, 6, 8, 6], 6, false);
+               animation.add("d", [1, 0, 2, 0], 6, false);

                drag.x = drag.y = 1600;
                setSize(8, 8);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions