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
代表滑鼠或筆的移動。
說明
Stores information about a mouse or a pen motion. This includes relative position, absolute position, and velocity. See Node._input().
Note: By default, this event is only emitted once per frame rendered at most. If you need more precise input reporting, set Input.use_accumulated_input to false to make events emitted as often as possible. If you use InputEventMouseMotion to draw lines, consider using Geometry2D.bresenham_line() as well to avoid visible gaps in lines if the user is moving the mouse quickly.
Note: This event may be emitted even when the mouse hasn't moved, either by the operating system or by Godot itself. If you really need to know if the mouse has moved (e.g. to suppress displaying a tooltip), you should check that relative.is_zero_approx() is false.
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
屬性說明
使用手寫筆的橡皮端時,返回 true。
注意:這個屬性在 Linux、macOS 和 Windows 上實作。
表示使用者對筆施加的壓力。範圍從 0.0 到 1.0 。
Vector2 relative = Vector2(0, 0) 🔗
The mouse position relative to the previous position (position at the last frame).
Note: Since InputEventMouseMotion may only be emitted when the mouse moves, it is not possible to reliably detect when the mouse has stopped moving by checking this property. A separate, short timer may be necessary.
Note: relative is automatically scaled according to the content scale factor, which is defined by the project's stretch mode settings. This means mouse sensitivity will appear different depending on resolution when using relative in a script that handles mouse aiming with the Input.MOUSE_MODE_CAPTURED mouse mode. To avoid this, use screen_relative instead.
Vector2 screen_relative = Vector2(0, 0) 🔗
The unscaled mouse position relative to the previous position in the coordinate system of the screen (position at the last frame).
Note: Since InputEventMouseMotion may only be emitted when the mouse moves, it is not possible to reliably detect when the mouse has stopped moving by checking this property. A separate, short timer may be necessary.
Note: This coordinate is not scaled according to the content scale factor or calls to InputEvent.xformed_by(). This should be preferred over relative for mouse aiming when using the Input.MOUSE_MODE_CAPTURED mouse mode, regardless of the project's stretch mode.
Vector2 screen_velocity = Vector2(0, 0) 🔗
The unscaled mouse velocity in pixels per second in screen coordinates. This velocity is not scaled according to the content scale factor or calls to InputEvent.xformed_by().
Note: In Input.MOUSE_MODE_CAPTURED mode, screen_velocity returns (0, 0) because the mouse cursor is hidden and locked. Use screen_relative for mouse aiming using the Input.MOUSE_MODE_CAPTURED mouse mode.
Vector2 tilt = Vector2(0, 0) 🔗
代表筆的傾斜角度。正的 X 座標值表示向右傾斜。正的Y座標值表示向使用者自身傾斜。兩個軸的範圍是 -1.0 到 1.0。
Vector2 velocity = Vector2(0, 0) 🔗
The mouse velocity in pixels per second.
Note: velocity is automatically scaled according to the content scale factor, which is defined by the project's stretch mode settings. That means mouse sensitivity may appear different depending on resolution.
Note: In Input.MOUSE_MODE_CAPTURED mode, velocity returns (0, 0) because the mouse cursor is hidden and locked. Use screen_relative for mouse aiming using the Input.MOUSE_MODE_CAPTURED mouse mode.