Flash CS6动作脚本2 hitTest不起作用

时间:2014-12-03 13:02:01

标签: flash actionscript-2 hittest

我的动作脚本2 hitTest不起作用。我试过寻找答案,但一无所获。 hitTest没有响应我分配给它的gotoAndStop。 这是我的代码:

walkspeed = 25;
jumping = false;
scottjab = false;
crouching = false;
scottslash = false;



scott.onEnterFrame = function(){
if(Key.isDown(Key.DOWN) && !jumping && !scottjab && !crouching){
    this.gotoAndStop("scottCrouch");
    crouching = true;
} else if(Key.isDown(78) && !jumping && !scottjab && !crouching){
    this.gotoAndStop("scottJab");
    scottjab = true;
} else if(Key.isDown(77) && !jumping && !scottjab && !crouching){
    this.gotoAndStop("scottSlash");
    scottslash = true;
} else if(Key.isDown(Key.UP) && !jumping && !scottjab && !crouching){
    this.gotoAndStop("scottJump");
    jumping = true;
} else if(Key.isDown(Key.LEFT) && !jumping && !scottjab && !crouching){
    this._x -= walkspeed;
    this.gotoAndStop("scottWalk");
} else if(Key.isDown(Key.RIGHT) && !jumping && !scottjab && !crouching){
    this._x += walkspeed;
    this.gotoAndStop("scottWalk");
} else if(!jumping && !scottjab && !crouching){
    this.gotoAndStop("scottIdle");
}
} 

ilsa.onEnterFrame = function(){
if(scott.scottJab.pad.hitTest(this)){
    this.gotoAndStop("ilsa Hit");
} else {
    this.gotoAndStop("ilsa Idle");
}
}

这两个字符(' scott'和' ilsa')也在不同的图层上,如果有帮助的话。并且文件中共有4个场景。

我感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

您的问题来自您的if语句:

if (scott.scottJab.pad.hitTest(this)) {/* ... */}

您定位的对象doesn't existisn't namedcorrectly named。名为pad的对象中是否包含名为scottJab的对象,该对象包含在名为scott的对象中?