Animation
Use a spritesheet to create an animation
Animations are created using spritesheets, and are then added to sprites.
App = function()
{
this.load = function()
{
wade.loadImage('/snippets/samples/dragon_flap.png');
};
this.init = function()
{
// create a sprite
var sprite = new Sprite();
// create an animation from a spritesheet (8 frames: 4x2)
var animation = new Animation('/snippets/samples/dragon_flap.png', 4, 2, 30, true);
sprite.addAnimation('flap', animation);
// create a scene object and add it to the scene
var dragon = new SceneObject(sprite);
wade.addSceneObject(dragon);
// the animation is just the dragon opening its wings.
// To make it flap its wings, we play it in 'ping-pong' mode
dragon.playAnimation('flap', 'ping-pong');
};
};
Your code was executed successfully!