Skip to main content

Mouse

Description:

  An interface for handling mouse inputs.

position

Type: Readonly Field.

Description:

  The position of the mouse in the visible window. You can use Mouse.position * App.devicePixelRatio to get the coordinate in the game world. Then use node:convertToNodeSpace() to convert the world coordinate to the local coordinate of the node.

Signature:

const position: Vec2

Usage:

local worldPos = Mouse.position * App.devicePixelRatio
local nodePos = node:convertToNodeSpace(worldPos)

leftButtonPressed

Type: Readonly Field.

Description:

  Whether the left mouse button is being pressed down.

Signature:

const leftButtonPressed: boolean

rightButtonPressed

Type: Readonly Field.

Description:

  Whether the right mouse button is being pressed down.

Signature:

const rightButtonPressed: boolean

middleButtonPressed

Type: Readonly Field.

Description:

  Whether the middle mouse button is being pressed down.

Signature:

const middleButtonPressed: boolean

wheel

Type: Readonly Field.

Description:

  The mouse wheel value.

Signature:

const wheel: number