Skip to content

getTouch() and getTouchRect() Usage

KonPet edited this page Jan 10, 2021 · 7 revisions

Made with help from PolyMars and ngawung

Description

getTouch() Gets the Status of the stylus (eg pressed or not pressed). This is integrated into getTouchRect() but can be used on it's own

getTouchRect() Check's if you are touching/holding/not touching a defined area

Values:

bool getTouch(
    KeyPhase phase // KeyPhase enum
)
bool getTouchRect(
    int x, int y,          // Position of the rectangle 
    int width, int height, // Dimensions of the rectangle
    KeyPhase phase         // KeyPhase enum
)

KeyPhase enum contain:
press, held, release

Example:

if(getTouch(KeyPhase::press){
    [YOUR CODE HERE]
}
if(getTouchRect(0, 0, 16, 16, KeyPhase::press)){ //Checks if the 16X16 area in the coordinates X:0 Y:0 are touched
    [YOUR CODE HERE]
}

Clone this wiki locally