EaselJS BitmapAnimation问题

时间:2013-03-05 11:51:13

标签: javascript easeljs

我的代码就像这样

<script src="http://code.createjs.com/easeljs-0.6.0.min.js"></script>
<script src="http://code.createjs.com/preloadjs-0.3.0.min.js"></script>
<script type="text/javascript" src="src/easeljs/utils/UID.js"></script>
<script type="text/javascript" src="src/easeljs/geom/Matrix2D.js"></script>
<script type="text/javascript" src="src/easeljs/display/DisplayObject.js"></script>
<script type="text/javascript" src="src/easeljs/display/Container.js"></script>
<script type="text/javascript" src="src/easeljs/display/Stage.js"></script>
<script type="text/javascript" src="src/easeljs/events/MouseEvent.js"></script>
<script type="text/javascript" src="src/easeljs/display/Shape.js"></script>
<script type="text/javascript" src="src/easeljs/display/Graphics.js"></script>
<script type="text/javascript" src="src/easeljs/utils/Ticker.js"></script>
<script type="text/javascript" src="src/easeljs/display/SpriteSheet.js"></script>
<script type="text/javascript" src="src/easeljs/display/BitmapAnimation.js"></script>
<script type="text/javascript" src="src/easeljs/geom/Rectangle.js"></script>

<script>
var canvas;var stage;var rect;var bottle;
function init() {
canvas = new createjs.Stage("democanvas");
sheet = {"frames": [[120, 0, 60, 200, 0, -20, 0], [180, 0, 60, 200, 0, -20, 0], [240, 0, 58, 200, 0, -21, 0], [62, 0, 58, 200, 0, -21, 0], [0, 0, 62, 200, 0, -19, 0]], "images": ["swf/bottle.png"], "animations": {"sosro": {"frames": [1]}, "nu": {"frames": [2]}, "joy": {"frames": [0]}, "tra": {"frames": [4]}, "mizone": {"frames": [3]}}};
var ss = new createjs.SpriteSheet(sheet);
bottle = new createjs.BitmapAnimation(ss);
    canvas.addChild(bottle);
    bottle.x = 100;
    bottle.y = 100;
    createjs.Ticker.addEventListener('tick', canvas);
}
</script>
<canvas id="democanvas" width="500" height="200"  style="border:1px solid #000000; background-color:#999;" >
alternate content
</canvas>
<script>
    init();
</script>

但不知怎的,我的动画片不会显示出来。我用Zoe来制作png javascript动画。我的剧本中缺少什么东西吗?

1 个答案:

答案 0 :(得分:1)

我在社区网站上回答了这个问题。 http://community.createjs.com/discussions/easeljs/967-bitmapanimataion-wont-show

确保在BitmapAnimations上使用gotoAndStop或gotoAndPlay,否则它们将无法显示。