Reputation: 61
I'm currently trying to figure out how to animate the sprite properly without the help of extra libraries other than jQuery. This is the live demo of what I have right now.
Controls: A for left, D for right, Space for jump, left mouse click to fire.
Here's the problem: if I press the left and right keys really fast, the animation gets screwed up, try it yourself since It's kind of hard to describe the mess...
My code is very scrappy right now because I'm playing around with many methods, so please bear with me for now. Here's the JavaScript code. If you want to see the html and css, they are in the same directory.
$('#obj') is the object of the sprite.
Upvotes: 1
Views: 114
Reputation: 207511
I am too lazy to look at the links for your code. If you say it is acting crazy, sounds like you are not cancelling the animations before applying the next one. Call stop()
before running the next animation.
$("#obj").stop().animate(...)
Upvotes: 1