mousePressRect

mousePressRect( )

Description

Define an invisible touch event area 

Syntax
mousePressRect(x, y, w, h, id) 


Parameters

  x : x-coordinate
  y : y-coordinate

  w : width
  h : height

  id : id of mousePressRect (range : 1 ~ 9)


Usages

mousePressRect(100, 200, 120, 80, 1)


Examples in arduino

#include "AppGosu.h"
AppGosu app;

int LED = 13;

void setup() {    

    pinMode(LED,OUTPUT);
    digitalWrite(LED, HIGH); // LED on
    app.start();
    app.setDelayCmd(20);  // max speed 20ms

    myStart();
}

void loop() {
  
 
} // end of loop

//---------------------------------------------------------
void serialEvent() {
      app.serialMessage();
      EventLoop();
}
void EventLoop() {
    if( app.btConnected()) {   // for auto starting
        myStart();
    }
  
    // user event code here
      
        if( app.eventMousePressRect(1)) {    // event handler
            app.image("appledOn.png", 120, 220, 250, 380);
            digitalWrite(LED, HIGH); // LED on
        }
        if( app.eventMousePressRect(2)) {
            app.image("appledOff.png", 120, 220, 250, 380);
            digitalWrite(LED, LOW); // LED off                
        }

}
//---------------------------------------------------------
void myStart(void) {
    // user starting code here
 
    app.clearAll();
    app.background(0,0,0);
    app.textSize(50);
    app.fill(255,255,255);
    app.text("-- mousePressRect --", 20, 50);
  
    // mousePressRect
    app.mousePressRect(120, 220, 250, 200, 1);
    app.mousePressRect(120, 420, 250, 200, 2);
  
    app.image("appledOff.png", 120, 220, 250, 380);

}














by AppGosu
-----------------------------------------









No comments: