I need to be able to change the fps while the program is running, is it possible? I think the code is right but it doesn’t work
import g4p_controls.*;
GImageToggleButton btn1,btn2,btn4,btn8;
public int fps = 30;
public void setup(){
size(1200,700);
frameRate(fps);
//G4P.setCursor(ARROW);
btn1 = new GImageToggleButton(this, 1050,400,"imagens/1x.png",1,1);
btn2 = new GImageToggleButton(this, 1100,400,"imagens/2x.png",1,1);
btn4 = new GImageToggleButton(this, 1050,450,"imagens/4x.png",1,1);
btn8 = new GImageToggleButton(this, 1100,450,"imagens/8x.png",1,1);
}
public void draw(){
background(0);
println(frameRate);
}
public void handleToggleButtonEvents(GImageToggleButton button, GEvent event) {
//println(button.getState());
if(button == btn1){
println("botao 1x pressionado");
fps = 30;
}
if(button == btn2){
println("botao 2x pressionado");
fps = 60;
}
if(button == btn4){
println("botao 4x pressionado");
fps = 120;
}
if(button == btn8){
println("botao 8x pressionado");
fps = 240;
}
}