[英]CreateJS - Can't get my spritesheet to animate
I've checked this forum/the internet/google forwards and backwards for my particular question, but to no avail. 我已经检查了这个论坛/互联网/谷歌对我的特定问题的来回查询,但无济于事。 I get examples that come close to mine - which I try to impart into my own example, but nothing doing. 我得到的示例与我的非常接近-我试图将其引入我自己的示例中,但无济于事。 Please help! 请帮忙! Again I apologize if this has been answered and I just overlooked, if so please throw me a link - otherwise here is my code: 再次抱歉,如果我已经回答了这个问题,但我只是忽略了,如果可以,请给我一个链接-否则,这是我的代码:
All I'm trying to do is animate a single sprite image of a jumping Mega Man. 我要做的就是为一个跳跃的《超人》的子画面制作动画。
Thanks, and Happy Holidays! 谢谢,节日快乐!
NOTE: Here the sprite I'm using 注意: 这里我正在使用的精灵
HERE IS MY: JsFiddle 这是我的: JsFiddle
var stage, canvas,
bmpA, data,
megaman, spriteSheet;
function Main() {
canvas = document.getElementById('canvas');
stage = new createjs.Stage(canvas);
container = new createjs.Container();
megaman = new Image();
megaman.src = "megaman__jump.png";
var bmpA = new createjs.Bitmap(megaman);
data = new createjs.SpriteSheet({
images: [bmpA],
frames: {
width: 79,
height: 139,
count: 7
},
animations: {
jump: [0, 6, "jump"]
}
});
spriteSheet = new createjs.BitmapAnimation(data);
spriteSheet.gotoAndPlay("jump");
createjs.Ticker.setFPS(30);
createjs.Ticker.addEventListener("tick", update);
}
function update(event) {
stage.addChild(spriteSheet);
stage.update();
}
</script>
</head>
<body onload = "Main();">
<canvas id = "canvas" width = "780" height = "300"
style = "border: 1px solid #000;"></canvas>
</body>
</html>
[1]: http://i.imgur.com/Q1OQM.png
Here is a quick edit. 这是一个快速编辑。 http://jsfiddle.net/lannymcnie/f58mr0Lk/9/ http://jsfiddle.net/lannymcnie/f58mr0Lk/9/
The fiddle "works" now, but the spritesheet dimensions don't seem right. 小提琴现在“有效”,但Spritesheet尺寸似乎不正确。 Have a look. 看一看。
data = new createjs.SpriteSheet({
images: ["http://i943.photobucket.com/albums/ad274/Rah5er0/megaman__jump.png~original"],
frames: {
width: 79,
height: 139,
count: 7
},
animations: {
jump: [0, 6, "jump"]
}
});
var sprite = new createjs.Sprite(data);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.