Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

InputEventMouseMotion

继承: InputEventMouse < InputEventWithModifiers < InputEventFromWindow < InputEvent < Resource < RefCounted < Object

代表鼠标或笔的移动。

描述

存储鼠标或笔的运动信息。支持相对位置、绝对位置和速度。见 Node._input

注意:默认情况下,该事件每个渲染帧最多只会发出一个。如果你需要更精确的输入汇报,请将 Input.use_accumulated_input 设置为 false,尽可能频繁地发出事件。如果你使用 InputEventMouseMotion 来画线,请考虑同时实现布雷森汉姆直线算法,以避免在用户快速移动鼠标时出现可见的线条空隙。

教程

属性

bool

pen_inverted

false

float

pressure

0.0

Vector2

relative

Vector2(0, 0)

Vector2

tilt

Vector2(0, 0)

Vector2

velocity

Vector2(0, 0)


属性说明

bool pen_inverted = false

  • void set_pen_inverted ( bool value )

  • bool get_pen_inverted ( )

使用手写笔的橡皮端时,返回 true

注意:这个属性在 Linux、macOS 和 Windows 上实现。


float pressure = 0.0

  • void set_pressure ( float value )

  • float get_pressure ( )

表示用户对笔施加的压力。范围从 0.01.0


Vector2 relative = Vector2(0, 0)

鼠标相对于前一个位置的位置(上一帧的位置)。

注意:因为 InputEventMouseMotion 只在鼠标移动时发出,当用户停止移动鼠标时,最后一个事件的相对位置不会是 Vector2(0, 0)


Vector2 tilt = Vector2(0, 0)

代表笔的倾斜角度。正的 X 坐标值表示向右倾斜。正的Y坐标值表示向用户自身倾斜。两个轴的范围是 -1.01.0


Vector2 velocity = Vector2(0, 0)

鼠标速度,以像素每秒为单位。