spritesheet-canvas
Small lib to easily create, tick and draw a spritesheet from one source image, rendering it to Canvas.
- Small
- Flexible
- Fits nicely into a canvas game
Install with:
npm install spritesheet-canvas --saveDev
### Try it
- Try it or see it in action in this JSFiddle ### Example code
var SpriteSheet = var walk_texture = ;walk_texturesrc = "./assets/images/walk_texture.png"; var walk_spritesheet = SpriteSheet; walk_spritesheet; //Help methods to toggle the statewalk_spritesheet; //Do this every game loop, advances the sequence by a 60th of a second by default. Will not advance if paused, so call this always and let the internal state dictate if the tick takes effectwalk_spritesheet; //Use your own methods for placing and rotating the canvas before drawingcontextcontext; //Draw the current sprite in the texturewalk_spritesheet; context;