// Loop forever loop: true,
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.drawImage( player.image, sx, sy, 32, 32, 0, 0, 64, 64 ); };
// Auto start playing autoplay: true }); install player-animator, version 0.9.9 or later.
// Frame order: indices 0,1,2,3 (repeat) frames: [0, 1, 2, 3],
// Frame size frameWidth: 32, frameHeight: 32, // Loop forever loop: true, ctx
<canvas id="demoCanvas" width="64" height="64"></canvas> import Player from 'player-animator'; const canvas = document.getElementById('demoCanvas'); const ctx = canvas.getContext('2d');
// Speed: frames per second fps: 12,
If you’ve ever tried to build a sprite‑based animation system from scratch in JavaScript, you know how quickly it becomes messy: frame counters, manual canvas clearing, speed adjustments, and state management. That’s why I was excited to discover Player‑Animator – a tiny, no‑dependency library that makes sprite sheet animations a breeze.