Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TurnBasedRPG: Incorrect walking animations #284

Open
Poobslag opened this issue Aug 19, 2021 · 2 comments
Open

TurnBasedRPG: Incorrect walking animations #284

Poobslag opened this issue Aug 19, 2021 · 2 comments

Comments

@Poobslag
Copy link

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);
@Geokureli
Copy link
Member

Geokureli commented Sep 14, 2021

even with this fix I don't like how the walking animation plays a full loop after you stop walking. typically I'll make a walk and an idle anim and switch between them like so:

animation.add("walk_lr", [4, 3, 5, 3], 6);
animation.add("walk_u", [7, 6, 8, 6], 6);
animation.add("walk_d", [1, 0, 2, 0], 6);
animation.add("idle_lr", [3])
animation.add("idle_u", [6]);
animation.add("idle_d", [0]);

also how did you show that diff text with github's markdown?

@Poobslag
Copy link
Author

I used the git diff command to generate that output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants