[英]Always Show Mouse Over Canvas
I'm working on a javascript/canvas game, and using mouse position to determine what blocks to dig. 我正在开发一个javascript / canvas游戏,并使用鼠标位置来确定要挖掘的块。 Whenever I use the movement controls the mouse disappears though, which is annoying because then I have stop moving and move the mouse to see its position again.
每当我使用移动控件时,鼠标都会消失,这很烦人,因为那时我已经停止移动并再次移动鼠标以查看其位置。
So I'm looking for a way to make the mouse always visible on the canvas, opposite to using CSS cursor: none
to make it invisible. 因此,我正在寻找一种使鼠标始终在画布上可见的方法,与使用CSS
cursor: none
相反cursor: none
一种方法使鼠标不可见。
Full project here: https://gist.github.com/TuckerFlynn/0a52278878a888b0f695 完整的项目在这里: https : //gist.github.com/TuckerFlynn/0a52278878a888b0f695
The mouse can certainly navigate off-canvas, so... 鼠标当然可以在画布外导航,因此...
mousemove
. mousemove
报告的当前鼠标位置绘制自己的“假光标”。 Your "fake" canvas cursor doesn't have to look like a mouse. 您的“伪”画布光标不必看起来像鼠标。 It could even be a simple cross.
它甚至可以是一个简单的十字架。 Or if you really want it to look like a mouse, then move an image of a mouse around the canvas.
或者,如果您真的希望它看起来像鼠标,则在画布上移动鼠标的图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.