jsprite
v1.6.12
Published
Quick and easy JavaScript sprites
Downloads
8
Maintainers
Readme
jSprite
Quick and easy JavaScript sprites for use in your html.
USAGE:
- Set spriteSheet to the src of the sprite sheet image
- Set container to the ID of the html element that will contain your sprite
- Set no of columns the sprite sheet has
- Set no of rows the sprite sheet has
- If your sprite is not aligned on the x axis correctly you can adjust the x offset viaw "widthOffset: -5"
- Set the timing of the sprite, note you can control the timings of each frame individually if you use timings and feed it an array of number matching the number of frames in your sprite.
NOTE: jSprite will resize the container to the dimensions it calculates the a single sprite frame to be, if you wish to adjust size of the sprite you can use transform scale via css or javascript.
let mySprite = new jSprite({
spriteSheet: "./images/sheet1.png",
container: "htmlID",
columns: 8,
rows: 4,
widthOffset: 0,
startFrame: 17,
length: 8,
timing: 75,
autoStart: true,
repeat: true,
onComplete: function,
onProgress: function,
onComplete: function,
onRepeat: function,
onStop: function
});
Parameters
Methods
USAGE DEMOS:
DEMO: https://aftc.io/jSprite/
Licence:
MIT License
Copyright (c) Darcey Lloyd
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.