【问题标题】:HitTestPoint not working, collisions not happeningHitTestPoint 不工作,没有发生碰撞
【发布时间】:2018-06-27 00:42:57
【问题描述】:

我正在尝试创建类似于 Impossible Quiz Question 5 (1st quiz) 的内容。但是 hitTestPoint 似乎没有读取。我不确定我的错误在哪里。

这是我的完整代码行。

stop();

blueTarget.addEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
function mousehandler2(e:MouseEvent):void {
    if (blueTarget.hitTestPoint(mouseX,mouseY,true)) {
        removeEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
        gotoAndStop("lose");
    }
}
nexttButton.addEventListener(MouseEvent.MOUSE_DOWN, mousehandler3);
function mousehandler3(e:MouseEvent):void {
    removeEventListener(MouseEvent.MOUSE_DOWN, mousehandler3);
    MovieClip(root).nextFrame();
}

感谢您的帮助!

【问题讨论】:

  • 如果stop(); 被删除了怎么办?
  • hiTestPoint 最常见的错误是方法参数很棘手:help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/… x 和 y 参数指定舞台坐标空间中的一个点,而不是包含显示对象的显示对象容器...
  • @StefansArya 当鼠标移到 blueTarget 上时,blueTarget 消失并且不会丢失屏幕

标签: actionscript-3 flash flash-cs4


【解决方案1】:

如果玩家将鼠标移到 blueTarget 上,您是否希望玩家输掉比赛?如果是这样,您可以删除您的 if 语句,因为鼠标悬停事件已添加到 blueTarget

【讨论】:

  • 当我取出if语句时,当鼠标移到蓝屏上时,蓝屏消失,并没有进入我的丢失屏幕:stop(); blueTarget.addEventListener(MouseEvent.MOUSE_OVER, mousehandler2); function mousehandler2(e:MouseEvent):void { removeEventListener(MouseEvent.MOUSE_OVER, mousehandler2); gotoAndStop("lose"); } } nexttButton.addEventListener(MouseEvent.MOUSE_DOWN, mousehandler3); function mousehandler3(e:MouseEvent):void { removeEventListener(MouseEvent.MOUSE_DOWN, mousehandler3); MovieClip(root).nextFrame(); }
  • 我认为这是因为您将 blueTarget 告诉 gotoAndStop("lose") 但我不知道您在哪里定义的。您是否在鼠标处理程序中尝试了MovieClip(root).gotoAndStop("lose")
猜你喜欢
  • 2012-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多