animateSprite
Sprite animations made simple
This is a work in progress, not ready for production. Please check the TODO list before doing anything serious with it.
Getting started
With Browserify
$ npm install --save animatesprite
var AnimateSprite = require('animatesprite');
var animation = new AnimateSprite(document.getElementById('domWithSprite'));
Browser
Download the production version or the development version.
In your web page:
<script src="dist/animatesprite.min.js"></script>
<script>
var animation = new AnimateSprite(document.getElementById('domWithSprite'), {
fps: 12,
animations: {
walkRight: [0, 1, 2, 3, 4, 5, 6, 7],
walkLeft: [15, 14, 13, 12, 11, 10, 9, 8]
},
loop: true,
complete: function(){
alert("animation End");
}
});
</script>
Settings
fps: int
complete: function
loop: bool
autoplay: bool
animations: object
Methods
animation.play('animatinName')
animation.stop()
animation.resume()
animation.restart()
animation.frame()
animation.frame(n)
animation.settings()
animation.settings({fps: 2})
TODO
This javascript module is not ready for a release yet:
- frame method sets what I call animation key (position from the current animation), but returns animation frame (frame defined by the user).
- Some cleanup needs to be done, and give some consistency to know private variables from public ones.
- It should plug in nicely with jQuery so it can replace jQuery.animateSprite.
License
MIT © Blai Pratdesaba