Buttons in same co-ordinates, in different sub-routines executing at same time.
in
Programming Questions
•
9 months ago
Hi there, I'm relatively new to Processing, and like the language, but have run into a problem I can't seem to fix.
if ((mousePressed == true) && (mouseX >= 0) && (mouseX <= 120) && (mouseY>=0) && (mouseY <= 50) && (stopbutton7=true)){
slider3pos = slider3x + (slider3length/2); // Ignore this
slider4pos = slider4x + (slider4length/2); // And this
loopsim2=false; //So, the idea is that before this if statement, a simulation was rendered in a subroutine, loopsim 2 //controls the iteration of the previous simulation in void draw()
background(150);
loopsim3=true; //If this if statement executes, it means the user has pressed a button that should take //them to the nextsimulation, and loopsim3 is the variable that controls the iteration of the next simulation. //However, in the next simulation, this code seems to be causing problems:
if ((mousePressed == true) && (mouseX >= 0) && (mouseX <= 120) && (mouseY>=0) && (mouseY <= 50)) {
loopsim3=false; } //For the record, this is part of a different sub-routine to the previous simulation, I can post all of the //code if required, but i'd rather not. This button is in the exact same co-ordinates as the button in the previous screen.
// However, while before implementing this button the simulation worked, now it does not loop whatsoever, as if the press
// of the button from the previous screen satisfies this if statement, which it should not as it occurs in a different sub-//routine. I have also tried implementing other variables set at different times in the program, to no success.
1