Javascript 在EaselJS中设置精灵表动画时遇到问题

Javascript 在EaselJS中设置精灵表动画时遇到问题,javascript,html,canvas,easeljs,sprite-sheet,Javascript,Html,Canvas,Easeljs,Sprite Sheet,我正在尝试使用EaselJS制作一个精灵表的动画,但我一直得到一个未捕获的类型错误:未定义不是此行的函数-bmpAnimation=new createjs.BitmapAnimation(精灵表) 以下是我目前的代码: // JavaScript Document window.onload = function(){ //Creating a new Stage instance, passing in our canvas element's ID. var stage = new cr

我正在尝试使用EaselJS制作一个精灵表的动画,但我一直得到一个未捕获的类型错误:

未定义不是此行的函数-
bmpAnimation=new createjs.BitmapAnimation(精灵表)


以下是我目前的代码:

// JavaScript Document
window.onload = function(){

//Creating a new Stage instance, passing in our canvas element's ID.
var stage = new createjs.Stage("canvas"),

imgMonsterARun = new Image();
imgMonsterARun.src = "img/MonsterARun.png";

    var spriteSheet = new createjs.SpriteSheet({
        // image to use
        images: [imgMonsterARun], 
        // width, height & registration point of each sprite
        frames: {width: 64, height: 64, regX: 32, regY: 32}, 
        animations: {    
            walk: [0, 9, "walk"]
        }
    });

    // create a BitmapAnimation instance to display and play back the sprite sheet:
    bmpAnimation = new createjs.BitmapAnimation(spriteSheet);

    // start playing the first sequence:
    bmpAnimation.gotoAndPlay("walk");     //animate

    // set up a shadow. Note that shadows are ridiculously expensive. You could display hundreds
    // of animated rats if you disabled the shadow.
    bmpAnimation.shadow = new createjs.Shadow("#454", 0, 5, 4);

    bmpAnimation.name = "monster1";
    bmpAnimation.direction = 90;
    bmpAnimation.vX = 4;
    bmpAnimation.x = 16;
    bmpAnimation.y = 32;

    // have each monster start at a specific frame
    bmpAnimation.currentFrame = 0;
    stage.addChild(bmpAnimation);

    createjs.Ticker.setFPS(60);
    createjs.Ticker.useRAF = true;
    createjs.Ticker.addListener(window);

        function tick() 
        {       
            // Hit testing the screen width, otherwise our sprite would disappear
            if (bmpAnimation.x >= screen_width - 16) {
                // We've reached the right side of our screen
                // We need to walk left now to go back to our initial position
                bmpAnimation.direction = -90;
            }

            if (bmpAnimation.x < 16) {
                // We've reached the left side of our screen
                // We need to walk right now
                bmpAnimation.direction = 90;
            }

            // Moving the sprite based on the direction & the speed
            if (bmpAnimation.direction == 90) {
                bmpAnimation.x += bmpAnimation.vX;
            }
            else {
                bmpAnimation.x -= bmpAnimation.vX;
            }

            // update the stage:
            stage.update();
        }
        tick();

};
//JavaScript文档
window.onload=函数(){
//创建一个新的Stage实例,传入canvas元素的ID。
var stage=new createjs.stage(“画布”),
imgMonsterARun=新图像();
imgMonsterARun.src=“img/MonsterARun.png”;
var spriteSheet=new createjs.spriteSheet({
//要使用的图像
图片:[imgMonsterARun],
//每个精灵的宽度、高度和注册点
帧:{宽度:64,高度:64,regX:32,regY:32},
动画:{
步行:[0,9,“步行”]
}
});
//创建位图动画实例以显示和播放精灵工作表:
bmpAnimation=新建createjs.BitmapAnimation(精灵表);
//开始播放第一个序列:
bmpAnimation.gotoAndPlay(“行走”);//设置动画
//设置一个阴影。请注意,阴影非常昂贵。您可以显示数百个阴影
//如果禁用阴影,则为已设置动画的老鼠。
bmpAnimation.shadow=newcreatejs.shadow(“#454”,0,5,4);
bmpAnimation.name=“monster1”;
bmpAnimation.direction=90;
bmpAnimation.vX=4;
bmpAnimation.x=16;
bmpAnimation.y=32;
//让每个怪物从特定的帧开始
bmpAnimation.currentFrame=0;
阶段。添加儿童(bmpAnimation);
createjs.Ticker.setFPS(60);
createjs.Ticker.useRAF=true;
createjs.Ticker.addListener(窗口);
函数tick()
{       
//点击测试屏幕宽度,否则我们的精灵就会消失
如果(bmpAnimation.x>=屏幕宽度-16){
//我们已经到达屏幕的右侧
//我们现在需要向左走才能回到初始位置
bmpAnimation.direction=-90;
}
如果(bmpAnimation.x<16){
//我们已经到达屏幕的左侧
//我们现在需要走路
bmpAnimation.direction=90;
}
//根据方向和速度移动精灵
如果(bmpAnimation.direction==90){
bmpAnimation.x+=bmpAnimation.vX;
}
否则{
bmpAnimation.x-=bmpAnimation.vX;
}
//更新阶段:
stage.update();
}
勾选();
};

任何帮助都将不胜感激。

在0.8.0中,您可以使用普通的
精灵表来创建动画精灵表。在上签出演示(确保在“实时编辑”;-)下检查代码)

尝试使用“精灵”而不是“位图动画”

就是

bmpAnimation = new createjs.BitmapAnimation(spriteSheet);
变成

bmpAnimation = new createjs.Sprite(spriteSheet);

为我工作。

解决了这个问题!版本0.8.0不支持位图动画,必须使用0.6.0