Super basic sprite sheet management
npm i @thibka/spritemanager
import SpriteManager from "@thibka/spritemanager"
<script src="SpriteManager-es5.js"></script>
<div id="mySpriteContainer"></div>
#mySpriteContainer {
width: 370px;
height: 370px;
background-position-x: 0;
background-position-y: 0;
background-repeat: no-repeat;
background-image: url(./img/mysprite.png);
background-size: 370px 3700px;
}
var mySprite = new SpriteManager({
container: document.getElementById('mySpriteContainer'),
fps: 25,
frameHeight: 370,
height: 3700,
loop: true, // Optional.
loopDelay: 500, // Optional. Delay between each loop
beforeLoop: function() {
// Optional. Triggered before each iteration of a loop
},
complete: function() {
// Optional. Triggered when animation is done (wheter in a loop or not)
}
});
mySprite.play();