Flash 中的 setCursorPos 问题 - Away3D

发布于 2024-10-11 06:44:09 字数 716 浏览 1 评论 0原文

我正在 Away3D 中为 Flash 制作第一人称射击游戏,但 setCursorPos 似乎无法正常工作。当我调用setCursorPos时,光标移动到屏幕中央,同时也触发了MOUSE_MOVE事件。这是预期的行为吗?我如何知道 MOUSE_MOVE 事件何时是由 setCursorPos; 引起的?或者是否是由实际的鼠标移动引起的?这是我正在尝试做的事情的代码示例:

private function onMove(evt:MouseEvent):void {
if (prevY == 0) {
                    prevY = evt.stageY;
                    prevX = evt.stageX;
                }
                    mainView.camera.rotate(Vector3D.X_AXIS,evt.stageY - prevY);

                }
            }
            //This triggers a MOUSE_MOVE event, causing this function to be called again.
                nativeInterface.setCursorPos(nativeInterface.screenResolution[0] / 2, nativeInterface.screenResolution[1] / 2);
}

I'm making a 1st person shooter for Flash in Away3D, but it seems that setCursorPos isn't working properly. When I call setCursorPos, the cursor moves to the center of the screen, but also triggers a MOUSE_MOVE event. Is this expected behavior? How do I know when the MOUSE_MOVE event is caused by the setCursorPos; or whether it's caused by actual mouse movement? Here is a code sample of what I'm trying to do:

private function onMove(evt:MouseEvent):void {
if (prevY == 0) {
                    prevY = evt.stageY;
                    prevX = evt.stageX;
                }
                    mainView.camera.rotate(Vector3D.X_AXIS,evt.stageY - prevY);

                }
            }
            //This triggers a MOUSE_MOVE event, causing this function to be called again.
                nativeInterface.setCursorPos(nativeInterface.screenResolution[0] / 2, nativeInterface.screenResolution[1] / 2);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

香橙ぽ 2024-10-18 06:44:09

我对nativeInterface和setCursorPos不熟悉。你能否提供更多细节?这是 Away3D 还是 Away3DLite?

要区分两者,首先想到的是检查 eventPhase 并基于此执行和 if 语句,如果 eventPhase 不同,具体取决于触发事件的时间/内容。

华泰

I'm not familiar with nativeInterface and setCursorPos. Could you give a few more details ? Is this Away3D or Away3DLite ?

The first thing that comes to mind to separate the two is checking the eventPhase and doing and if statement based on that, if the eventPhase is different depending when/what triggers the event.

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文