Easeljs Animate Though Frames Based In Current Frame
I'm working with EaselJS SpriteSheets and I want to know how I can make my hero stop running smoothly, So if the SpriteSheet is playing the 'run' animation and it's on frame 5, I'l
Solution 1:
When re-formulating my question I understood my problem better and solved it. Thank you, StackOverflow.
So, I was thinking I would need to get the actual frame number, and then add/subtract it by 1 every tick until it reaches the frame 0. Unfortunately, this method is overcomplicated and it would, obviously, compromise maintainability.
I've solved my problem by checking if the currentFrame
property is equal to zero. if it isn't then the animation proceeds, else, the animation stops.
Here's the resulting code:
if ((user.input.left || user.input.right) && !user.hero.jumping) {
changeAnimation(user.hero, "run");
} elseif (!user.hero.jumping && user.hero.animation != "stopFalling" && user.hero.animation != "almostFalling") {
if (!(user.hero.animation == "run" && user.hero.currentFrame != 0)) {
changeAnimation(user.hero, "stand");
}
}
Post a Comment for "Easeljs Animate Though Frames Based In Current Frame"