下载Cocos Creator
来源:Cocos
浏览 353
扫码
分享
2022-03-09 22:51:59
Global and Node Touch and Mouse Events API
Mouse Event API
Function Name | Return value type | Meaning |
---|
getScrollY | Number | Get the scrolling distance of the mouse wheel on the y-axis, valid only when scrolling. |
getButton | Number | Event.EventMouse.BUTTON_LEFT or Event.EventMouse.BUTTON_RIGHT or Event.EventMouse.BUTTON_MIDDLE. | |
Global Mouse Events API
Function Name | Return value type | Meaning |
---|
getLocation | Vec2 | Get the mouse position, which contains the x and y properties. |
getLocationX | Number | Get the mouse position on x-axis. |
getLocationY | Number | Get the mouse position on y-axis. |
getPreviousLocation | Vec2 | Get the position of the last triggered mouse event, which contains the x and y properties. |
getDelta | Vec2 | Get the distance the mouse has moved relative to the lower-left corner since the last event, which contains the x and y properties. |
getDeltaX | Number | Get the x-axis distance the mouse has moved relative to the lower-left corner since the last event. |
getDeltaY | Number | Get the y-axis distance the mouse has moved relative to the lower-left corner since the last event. |
Node Mouse Events API
Function Name | Return value type | Meaning |
---|
getUILocation | Vec2 | Get the current mouse position relative to the lower-left corner of the UI window, which contains the x and y properties. |
getUILocationX | Number | Get the position of the touch point on the x-axis relative to the lower-left corner of the UI window. |
getUILocationY | Number | Get the current mouse position on y-axis relative to the lower-left corner of the UI window. |
getUIPreviousLocation | Vec2 | Get the previous mouse position relative to the lower-left corner of the UI window, which contains the x and y properties. |
getUIDelta | Vec2 | Get 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. |
getUIDeltaX | Number | Get the x-axis distance the mouse has moved relative to the lower-left corner of the UI window since the last event. |
getUIDeltaY | Number | Get 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 Name | Type | Meaning |
---|
touch | Touch | The touch point related to the current event. |
getID | Number | Get the ID of the touch point, which is used for multi-touch logic. |
Global Touch Events API
Function Name | Return value type | Meaning |
---|
getLocation | Vec2 | Get the mouse position, which contains the x and y properties. |
getLocationX | Number | Get the position of the touch point on the x-axis. |
getLocationY | Number | Get the position of the touch point on the y-axis. |
getStartLocation | Vec2 | Get the initial position of the touch point, which contains the x and y properties. |
getPreviousLocation | Vec2 | Get the position of the last triggered touch point event, which contains the x and y properties. |
getDelta | Vec2 | Get 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 Name | Return value type | Meaning |
---|
getUILocation | Vec2 | Get the current mouse position relative to the lower-left corner of the UI window, which contains the x and y properties. |
getUILocationX | Number | Get the current mouse position on x-axis relative to the lower-left corner of the UI window. |
getUILocationY | Number | Get the current mouse position on y-axis relative to the lower-left corner of the UI window. |
getUIStartLocation | Vec2 | Get the position of the initial touch point relative to the lower-left corner of the UI window, which contains the x and y properties. |
getUIPreviousLocation | Vec2 | Get the position of the last touch point relative to the lower-left corner of the UI window, which contains the x and y properties. |
getUIDelta | Vec2 | Get 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. |
当前内容版权归
Cocos 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问
Cocos .