Easy Sprite Animation Using jQuery and Html5 Canvas - spriteAnimate

File Size: 15.2 KB
Views Total: 2767
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Easy Sprite Animation Using jQuery and Html5 Canvas - spriteAnimate

Just another jQuery Spritesheet Animation plugin used to animate a sprite sheet with linear or a grid of frames using HTML5 canvas and requestAnimationFrame.

How to use it:

1. Create an HTML5 canvas element for the Spritesheet Animation.


2. Put jQuery library and the jQuery spriteAnimate plugin at the bottom of the html page.

<script src="//code.jquery.com/jquery-3.1.0.slim.min.js"></script>
<script src="sprite-animate.js"></script>

3. Call the plugin on the canvas element, specify the path to the sprite sheet, and set the height, width and number of sprite frames.

var $canvas = $('canvas');
  frameWidth: 150,
  frameHeight: 150,
  numberOfFrames: 4,
  imgSrc: "demo.png"

4. Start the sprite animation.


5. Full configuration options with default values.

frameWidth: null,
frameHeight: null,
numberOfFrames: null,
imgSrc: null,
fps: null,
loop: true,
jumpFrame: null,
debug: false,
onReady: function(){},
onFinish: function(){}

6. API methods.

// pause the animation

// restart the animation

// goto a specified frame
$canvas.spriteAnimate('goTo', 3);

// get the current frame

Change log:


  • added onReady callback.

This awesome jQuery plugin is developed by augoisms. For more Advanced Usages, please check the demo page or visit the official website.