Skip to content

Tutorial Pt. 4 contains sprite animation error #237

Open
@Prid13

Description

@Prid13

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

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