-2

I just begin using EaselJS, and I have some issues with sprites. I want to animate a spritesheet, my code seems right but i still have a white canvas. Could you help me to tell me where I am wrong ?

    var img = new Image(),
        canvas,
        stage,
        bmpAnimation;

function init() {
    canvas = document.getElementById("myCanvas");
    stage = new createjs.Stage(canvas);
    img.src = "http://untamed.wild-refuge.net/images/rpgxp/avengers/deadpool.png";
    createjs.Ticker.useRAF = true;
    createjs.Ticker.setFPS(40);
    createjs.Ticker.addEventListener("tick",tick);
}
var spriteSheet = new createjs.SpriteSheet({
    images: [img],
    frames: {width:32, height:48, regX: 16, regY: 24},
    animations: {
    walk: [4, 7, "walk"]
    }
});
function tick() {
scene.update();
}
bmpAnimation = new createjs.BitmapAnimation(spriteSheet);
bmpAnimation = gotoAndPlay("walk");
bmpAnimation.x = 200;
bmpAnimation.y = 100;
bmpAnimation.currentFrame = 0;
stage.addChild(bmpAnimation);
window.onload = init;

Thank you.

nicoolaslb
  • 67
  • 1
  • 3
  • 8

1 Answers1

2

Check your console output. You have a number of typos that are causing errors. For example, you are calling scene.update() instead of stage.update() and bmpAnimation = gotoAndPlay("walk") instead of bmpAnimation.gotoAndPlay("walk").

Please try to take basic debugging steps to resolve your problems, and review your own code prior to asking for help on SO.

gskinner
  • 2,478
  • 11
  • 12