我正在编写游戏,需要捕获Firefox中的鼠标移动。这是我的代码:在Firefox中捕捉鼠标移动
document.onmousemove = function(e) {
mouseState.x = e.x;
mouseState.y = e.y;
}
它在Chrome/IE中正常工作,但它似乎并没有在Firefox中工作。当我做console.log(mouseState.x)
时,它返回为undefined
。
我需要做些什么修改才能使Firefox捕获鼠标移动?