going back and forth (layout or screen) upon clicking a button !
in
Programming Questions
•
1 year ago
hi
this is my post !! So guys please help i find my self in a great trouble .
want or desire ::
i have created 3 icons(buttons) on the screen and want to link to a different screen when i click the any of the button out of three,and then again from the second screen want to switch back to the first screen with all the 3 previous buttons intact when i click the back button situated on the 2nd screen . (back is now where 'written' in my code at this moment but is done or happens when somebody presses the left button fond on the 2nd screen)
i whole concept is similar to the one found in games.i.e when somebody click the scores he is taken on to the score layout and when he click's the back button he again reached the first screen with normal functioning.
kindly suggest some other way or some other tutorial that would solve my problem.
i even am scrounging in controlP5 library for getting my answer please help!!
drawbacks or faults ::
this is a small part of my code but what is intended to show is that in this code when i click the first button then it goes to the "so called" 2nd screen but do not switch back to the 1st one .
another drawback is that if use the similar concept to do the same task upon linking each buttons then on the arrival of the 2nd screen if we press within the same coordinate(i.e. on the background) anoother screen opens up that is maybe link to the 1,2,or 3 rd button.
code::(with only first button linked)
float r,a=1;
float p=1;
void setup()
{
size(500, 500);
smooth();
stroke(2);
}
void draw()
{
/*----------------------------------------------------*/
for (int i =500; i >0; i--) {
stroke(120, 224,500-i);
line( 500, i,0,i);
}
//1st ellipse
// inner ellipse having "text" written
fill(#56BCF2,80);
ellipse(250, 210, 130*a, 50*a);
//2nd ellipse
fill(#56BCF2,80);
ellipse(250,280,130*a,50*a);
//3rd ellipse
fill(#56BCF2,80);
ellipse(250,350,130*a,50*a);
//creation of font
if (r==2) //------<<<<r=2>>>>-----
{
for (int i =500; i >0; i--)
{
stroke(120, 224,500-i);
line( 500, i,0,i);
}
ellipse(300,230,50*p,25*p);
fill(0,170,222);
ellipse(150,230,50*p,25*p);
}
/*----------------------------------------------------*/
/*----------------------------------------------------*/
if (r==3) //------<<<<r=3>>>>-----
{
for (int i =500; i >0; i--)
{
stroke(120, 224,500-i);
line( 500, i,0,i);
}
rect(100,100,300,300);
ellipse(450,450,50,25);
}
/*----------------------------------------------------*/
}
void mousePressed(){
if( (mouseX >185 && mouseX <315) &&(mouseY >185 && mouseY <235) )
{
a=0;
r=2;
p=1;
}
if( (mouseX >128 && mouseX <162) &&(mouseY >205 && mouseY <255) )
{
a=1;
r=2;
p=0;
}
}
1