InputEventMouseMotion

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

Represents a mouse or a pen movement.

描述

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.

属性


属性说明

bool pen_inverted = false

  • void set_pen_inverted ( value: bool )
  • bool get_pen_inverted ( )

Returns true when using the eraser end of a stylus pen.

Note: This property is implemented on Linux, macOS and Windows.


float pressure = 0.0

  • void set_pressure ( value: float )
  • float get_pressure ( )

Represents the pressure the user puts on the pen. Ranges from 0.0 to 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)

  • void set_screen_relative ( value: Vector2 )
  • Vector2 get_screen_relative ( )

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)

  • void set_screen_velocity ( value: Vector2 )
  • Vector2 get_screen_velocity ( )

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. This should be preferred over velocity for mouse aiming when using the Input.MOUSE_MODE_CAPTURED mouse mode, regardless of the project's stretch mode.


Vector2 tilt = Vector2(0, 0)

Represents the angles of tilt of the pen. Positive X-coordinate value indicates a tilt to the right. Positive Y-coordinate value indicates a tilt toward the user. Ranges from -1.0 to 1.0 for both axes.


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. This means mouse sensitivity will appear different depending on resolution when using velocity in a script that handles mouse aiming with the Input.MOUSE_MODE_CAPTURED mouse mode. To avoid this, use screen_velocity instead.

1

本方法通常需要用户覆盖才能生效。

2

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。