Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
InputEventMouseMotion¶
继承: InputEventMouse < InputEventWithModifiers < InputEventFromWindow < InputEvent < Resource < RefCounted < Object
代表鼠标或笔的移动。
描述¶
存储鼠标或笔的运动信息。支持相对位置、绝对位置和速度。见 Node._input。
注意:默认情况下,该事件每个渲染帧最多只会发出一个。如果你需要更精确的输入汇报,请将 Input.use_accumulated_input 设置为 false
,尽可能频繁地发出事件。如果你使用 InputEventMouseMotion 来画线,请考虑同时实现布雷森汉姆直线算法,以避免在用户快速移动鼠标时出现可见的线条空隙。
教程¶
属性¶
|
||
|
||
|
||
|
||
|
属性说明¶
bool pen_inverted = false
使用手写笔的橡皮端时,返回 true
。
注意:这个属性在 Linux、macOS 和 Windows 上实现。
float pressure = 0.0
表示用户对笔施加的压力。范围从 0.0
到 1.0
。
Vector2 relative = Vector2(0, 0)
鼠标相对于前一个位置的位置(上一帧的位置)。
注意:因为 InputEventMouseMotion 只在鼠标移动时发出,当用户停止移动鼠标时,最后一个事件的相对位置不会是 Vector2(0, 0)
。
Vector2 tilt = Vector2(0, 0)
代表笔的倾斜角度。正的 X 坐标值表示向右倾斜。正的Y坐标值表示向用户自身倾斜。两个轴的范围是 -1.0
到 1.0
。
Vector2 velocity = Vector2(0, 0)
鼠标速度,以像素每秒为单位。