0
我正在使用easeljs和spritesheet创建一个我想要使用动画的游戏。我使用下面的代码来做到这一点,但动画似乎没有出现在我的画布上。这很奇怪,因为也没有错误。我究竟做错了什么?EaselJS spritesheet动画在画布上不可见,但没有错误
我的代码:
stage = new createjs.Stage(canvas);
sprite = new createjs.SpriteSheet({
"images": ["./images/vos.png"],
"frames": [[0, 0, 32, 32, 0, 0, 0],
[32, 0, 32, 32, 0, 0, 0],
[64, 0, 32, 32, 0, 0, 0],
[96, 0, 32, 32, 0, 0, 0]],
"animations": {"all": {"frames": [0, 1, 2, 3, 2, 1, 0]}
}
});
vos = new createjs.BitmapAnimation(sprite);
vos.x = 32 + (Math.random() * (canvas.width - 64));
vos.y = 32 + (Math.random() * (canvas.height - 64));
speed=8;
createjs.Ticker.addListener(window);
createjs.Ticker.setFPS(24);
stage.addChild(vos);
vos.gotoAndPlay('all');
只更新舞台的刻度方法的更好方法是将舞台添加为监听器。 Stage有一个'handleEvent'方法,它在收到tick事件时自动更新舞台。 – Lanny