【发布时间】:2013-08-03 18:57:52
【问题描述】:
所以我在 AS2.0 上制作了一个游戏,你可以控制一个可以移动的方格,并且你不应该接触任何墙壁,否则关卡会重置并且你会回到初始位置。我已经做到了,但是我必须为每面墙做一个如果,当我达到更大的水平时,这将是一项永恒的工作,即使我复制/粘贴。有什么方法可以同时测试多个对象吗? 谢谢 如果您需要,这是我的代码:D
on(keyPress "<Left>") {
this._x -= 5;
}
on(keyPress "<Right>") {
this._x += 5;
}
on(keyPress "<Down>") {
this._y += 5;
}
on(keyPress "<Up>") {
this._y -= 5;
}
onClipEvent(EnterFrame) {
if (_root.square.hitTest(_root.wall)) {
_root.touch._Alpha = 100;
this._x = _root.x0;
this._y = _root.y0;
}
if (_root.square.hitTest(_root.wall1)) {
_root.touch._Alpha = 100;
this._x = _root.x0;
this._y = _root.y0;
}
if (_root.square.hitTest(_root.wall2)) {
_root.touch._Alpha = 100;
this._x = _root.x0;
this._y = _root.y0;
}
if (_root.square.hitTest(_root.goal)) {
_root.gotoAndStop(3);
}
}
它是根据 Square 的动作制作的。
【问题讨论】:
标签: flash object actionscript-2 hittest