Global and Node Touch and Mouse Events API

Mouse Event API

Function NameReturn value typeMeaning
getScrollYNumberGet the scrolling distance of the mouse wheel on the y-axis, valid only when scrolling.
getButtonNumberEvent.EventMouse.BUTTON_LEFT or Event.EventMouse.BUTTON_RIGHT or Event.EventMouse.BUTTON_MIDDLE. |

Global Mouse Events API

Function NameReturn value typeMeaning
getLocationVec2Get the mouse position, which contains the x and y properties.
getLocationXNumberGet the mouse position on x-axis.
getLocationYNumberGet the mouse position on y-axis.
getPreviousLocationVec2Get the position of the last triggered mouse event, which contains the x and y properties.
getDeltaVec2Get the distance the mouse has moved relative to the lower-left corner since the last event, which contains the x and y properties.
getDeltaXNumberGet the x-axis distance the mouse has moved relative to the lower-left corner since the last event.
getDeltaYNumberGet the y-axis distance the mouse has moved relative to the lower-left corner since the last event.

Node Mouse Events API

Function NameReturn value typeMeaning
getUILocationVec2Get the current mouse position relative to the lower-left corner of the UI window, which contains the x and y properties.
getUILocationXNumberGet the position of the touch point on the x-axis relative to the lower-left corner of the UI window.
getUILocationYNumberGet the current mouse position on y-axis relative to the lower-left corner of the UI window.
getUIPreviousLocationVec2Get the previous mouse position relative to the lower-left corner of the UI window, which contains the x and y properties.
getUIDeltaVec2Get the distance the mouse has moved relative to the lower-left corner of the UI window since the last event, which contains the x and y properties.
getUIDeltaXNumberGet the x-axis distance the mouse has moved relative to the lower-left corner of the UI window since the last event.
getUIDeltaYNumberGet the y-axis distance the mouse has moved relative to the lower-left corner of the UI window since the last event.

Touch Events API

API NameTypeMeaning
touchTouchThe touch point related to the current event.
getIDNumberGet the ID of the touch point, which is used for multi-touch logic.

Global Touch Events API

Function NameReturn value typeMeaning
getLocationVec2Get the mouse position, which contains the x and y properties.
getLocationXNumberGet the position of the touch point on the x-axis.
getLocationYNumberGet the position of the touch point on the y-axis.
getStartLocationVec2Get the initial position of the touch point, which contains the x and y properties.
getPreviousLocationVec2Get the position of the last triggered touch point event, which contains the x and y properties.
getDeltaVec2Get the distance the mouse has moved relative to the lower-left corner since the last event, which contains the x and y properties.

Node Touch Events API

Function NameReturn value typeMeaning
getUILocationVec2Get the current mouse position relative to the lower-left corner of the UI window, which contains the x and y properties.
getUILocationXNumberGet the current mouse position on x-axis relative to the lower-left corner of the UI window.
getUILocationYNumberGet the current mouse position on y-axis relative to the lower-left corner of the UI window.
getUIStartLocationVec2Get the position of the initial touch point relative to the lower-left corner of the UI window, which contains the x and y properties.
getUIPreviousLocationVec2Get the position of the last touch point relative to the lower-left corner of the UI window, which contains the x and y properties.
getUIDeltaVec2Get the distance the mouse has moved relative to the lower-left corner of the UI window since the last event, which contains the x and y properties.