好的问题是,我试图让球体在接触到我的十字准线时消失,问题是无论十字准线是否接触它,球体都会消失。
我的符号是:
舞台上带有十字准线实例的十字准线
使用舞台上的targetBlue实例进行目标
Mouse.hide();
crossHair.startDrag(true);
stage.addEventListener(MouseEvent.CLICK, _onStageMouseDown);
function _onStageMouseDown(e:MouseEvent):void
{
if (crossHair.hitTestObject(targetBlue), true)
{
targetBlue.visible = false;
trace("the mouse is in the target");
} else if (crossHair.hitTestObject(targetBlue), false){
trace("the mouse is not in the target");
}
}
答案 0 :(得分:0)
你的If-Statement有点奇怪。 试试这样:
if (crossHair.hitTestObject(targetBlue) == true) {
targetBlue.visible = false;
trace("the mouse is in the target");
} else {
trace("the mouse is not in the target");
}
不过,既然你可能会制作某种射击游戏,我建议你查看hitTestPoint()
功能,这将更适合这个。