Flash 中的 setCursorPos 问题 - Away3D
我正在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对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