Help with methods(?)
in
Android Processing
•
1 year ago
I'm not sure if methods is the correct term, but I need some help with the following code:
I have written a code with 4 buttons, where the idea is you have to press the right button to get to go to the next screen.
My problem is that the second screen looks exactly like the first screen and the draw() function just jumps straight to the code for the second screen even though the button on screen one was never pressed.
Therefore, I would like to know two things:
How do I keep Processing from jumping from screen 1 to 2 before the intended button has been pushed?
How do I keep Processing from jumping from screen 1 to 2 before the intended button has been pushed?
How do I "freeze" the screen when the right button is pushed, so that you are able to know if you have continued to the next screen, since the first and second screen are identical.
My code looks like this:
PImage Knap, knapTrykket, greenKnap, greenKnapTrykket, redKnap,
redKnapTrykket, doh, Yeah, purpleKnap, yellowKnap;
void setup()
{
size(displayWidth, displayHeight);
greenKnap = loadImage("1.jpg");
redKnap = loadImage("2.jpg");
greenKnapTrykket = loadImage("1trykket.jpg");
redKnapTrykket = loadImage("2trykket.jpg");
doh = loadImage("doh.jpg");
Yeah = loadImage("Yeah.gif");
purpleKnap = loadImage("3.jpg");
yellowKnap = loadImage("4.jpg");
orientation(PORTRAIT);
}
void firstScreen(){
background(0, 187, 211);
image(greenKnap, 25, 25, displayWidth/2-37.5, displayHeight/2-37.5);
image(redKnap, displayWidth/2+12.5, 25, displayWidth/2-37.5, displayHeight/2-37.5);
image(purpleKnap, 25, displayHeight/2+12.5, displayWidth/2-37.5, displayHeight/2-37.5);
image(yellowKnap, displayWidth/2+12.5, displayHeight/2+12.5, displayWidth/2-37.5, displayHeight/2-37.5);
if(displayWidth/2+12.5 < mouseX && mouseX < displayWidth/2+12.5 + displayHeight/2-37.5 &&
25 < mouseY && mouseY < 25 + displayHeight/2-37.5) {
image(redKnapTrykket, displayWidth/2+12.5, 25, displayWidth/2-37.5, displayHeight/2-37.5);
}
}
void secondScreen(){
background(0, 187, 211);
image(greenKnap, 25, 25, displayWidth/2-37.5, displayHeight/2-37.5);
image(redKnap, displayWidth/2+12.5, 25, displayWidth/2-37.5, displayHeight/2-37.5);
image(purpleKnap, 25, displayHeight/2+12.5, displayWidth/2-37.5, displayHeight/2-37.5);
image(yellowKnap, displayWidth/2+12.5, displayHeight/2+12.5, displayWidth/2-37.5, displayHeight/2-37.5);
if(25 < mouseX && mouseX < 25 + displayWidth/2-37.5 &&
25 < mouseY && mouseY < 25 + displayHeight/2-37.5) {
image(greenKnapTrykket, 25, 25, displayWidth/2-37.5, displayHeight/2-37.5);
}
}
void draw(){
firstScreen();
secondScreen();
}
Hope you understand me and hope you can help :-)
1