【发布时间】:2015-05-21 13:57:55
【问题描述】:
我正在尝试让我的角色与我创建的墙壁发生碰撞,但我在这样做时遇到了困难,我尝试在其他线程中使用解决方案,但没有一个奏效。请帮忙。本质上,我得到了碰撞检测工作,但是它只有在单击时才会激活,并带有鼠标事件。
square1_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
stage.addEventListener(MouseEvent.MOUSE_UP, drop);
function drag(e: MouseEvent): void {
e.target.startDrag();
}
function drop(): void {
head_mc.x -= velocity;
stopDrag();
if (head_mc.hitTestObject(square2_mc)) {
velocity = 0;
trace("Collision detected!");
} else {
trace("No collision.");
velocity = 5;
}
}
我要做的是,让我的玩家模型head_mc 在与我的墙square_mc 碰撞时停止向右移动。它仅在我单击对象时才有效,我需要它仅通过使用箭头键将 head_mc 移动到块中来工作。
【问题讨论】:
标签: actionscript-3 flash collision detection