Example : button floating

Example  :  button floating




Arduino Code

// AppGosu  for smart phone


#include "AppGosu.h"
AppGosu app;

int btn_count = 0;

void setup() {     
  
  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.eventButton(1)) {
            app.clearButton(1);
            btn_count = btn_count + 1;
            app.button((String)btn_count, random(10,320), random(100,700), 170, 80, 1);
        }

}
//---------------------------------------------------------
void myStart(void) {
    // user starting code here
    app.clearAll();
    app.background(0,0,0);
    app.textSize(50);
    app.fill(255,255,255);
    app.text("--- button ---", 60, 50);
   
    // button
    app.button("button", 10, 100, 150, 80, 1);
    btn_count = 0;
}




No comments: