Thanks JohnG for the sample code.
I've followed it and now a get a NullPointerException
here is the code :
Quote:boolean[] area;
void setup(){
size(1024,768, P3D);
frameRate(30);
}
void draw(){
background(20);
if(mouseX <= 512 && mouseY <= 384 && !area[0]){
area[0] = true;
myFunction1();}
else{
area[0] = false;}
if(mouseX <= 1023 && mouseY <= 384 && !area[1]){
area[1] = true;
myFunction2();}
else{
area[1] = false;}
if(mouseX <= 512 && mouseY <= 767 && !area[2]){
area[2] = true;
myFunction3();}
else{
area[2] = false;}
if(mouseX <= 1023 && mouseY <= 767 && !area[3]){
area[3] = true;
myFunction4();}
else{
area[3] = false;}
}
void myFunction1(){
fill(255,0,0);
rect(0,0,512,384);}
void myFunction2(){
fill(0,255,0);
rect(512,0,512,384);}
void myFunction3(){
fill(0,0,255);
rect(0,384,512,384);}
void myFunction4(){
fill(255,255,255);
rect(512,384,512,384);}
what's wrong with this code ?
Also, i can't really find out in this code when the myFunction is shown only one time until the mouse leaves the area.
Because it is in draw(), it will be repeated 30 times per second.
My goal is to get the rectangle (where the mouse is detected) to be displayed only one time and disappear, even if the mouse remains and moves in its area .
Thanks for your help.