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

Tutorial Pt. 4 contains sprite animation error #237

Open
Prid13 opened this issue Apr 13, 2020 · 1 comment
Open

Tutorial Pt. 4 contains sprite animation error #237

Prid13 opened this issue Apr 13, 2020 · 1 comment

Comments

@Prid13
Copy link

Prid13 commented Apr 13, 2020

Part 4 - "Sprites and Animation" contains a slight error in the code.

In step 3, the code is supposed 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"

However, that doesn't seem to be working. After moving, the animation always stops on the last frame where one leg is out. Maybe the player sprite got updated after the tutorial and the frames changed?

Either way, the solution is simply to move the first frame numbers in each array to the very end of the array, like this:

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);

That way the animation sequence will end with the neutral pose.


Another solution I found online was to add the code below after if(up || down || left || right){:

else if(animation.curAnim!=null)
{
    animation.curAnim.curFrame = 0;
    animation.curAnim.pause();
}
@NQNStudios
Copy link
Contributor

I ran into the same problem, and also, the demo that shows the finished game here does. And so does the gif here

So this would need to be fixed in the tutorial, the gif, and the actual source code of flixel-demos here

Assuming fixing it in flixel-demos would propogate to the host of the IFrame here then I think everything would be fine.

I agree that the animation code needs to be explained more, per #241. Fixing this could be a good time to do that. I could PR flixel-docs and flixel-demos to do the work.

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