Skip to content

Instantly share code, notes, and snippets.

@ekelokorpi
Last active August 29, 2015 14:08
Show Gist options
  • Save ekelokorpi/f57eb1025fbcb37b0c87 to your computer and use it in GitHub Desktop.
Save ekelokorpi/f57eb1025fbcb37b0c87 to your computer and use it in GitHub Desktop.
SpriteSheet: Basic usage
// Creates spritesheet with frame size 138x100
var spritesheet = new game.SpriteSheet('spritesheet.png', 138, 100);
// Returns sprite using frame 0 from spritesheet
var sprite = spritesheet.frame(0);
sprite.addTo(this.stage);
// Returns 15 frames long animation, starting from frame 2
var anim = spritesheet.anim(15, 2);
anim.animationSpeed = 0.3;
anim.play();
anim.addTo(this.stage);
// Define animation frames with array
var anim = spritesheet.anim([0, 0, 1, 2, 3, 2]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment