发新话题
打印

[求救] 新手提问~~~关于hitTest的问题

新手提问~~~关于hitTest的问题

for (i=1; i<=3; i++) {

for (j=1; j<=3; j++) {


thisA = attachMovie("a", "a"+i, i, {_x:50, _y:100*i});


thisA.i = i;


thisA.txt = this.i;


thisA.onEnterFrame = function() {


this._x += 10;


};


thisB = attachMovie("b", "b"+j, 100+j, {_x:500, _y: (4-j)*100});


thisB.j = j;


thisB.txt = this.j;


thisB.onEnterFrame = function() {


this._x -= 8;


};


if (thisA.hitTest(thisB)) {

                    trace("true")

_root["a"+this.i]._y += 50;


_root["b"+this.j]._y -= 50;


}


}

}
这是我试验多个碰撞多个的问题,请高手指教~~~为什么无法trace("true")?

TOP

因为楼主代码中的if (thisA.hitTest(thisB)) {只会在初始化时检测一次,不会连续检测。

多个对象的碰撞请看看HBrO大虾的文章,他有一个习作中讲到这个问题。很容易搜索到。

TOP

谢谢版主

TOP

发新话题