Hello, I’ve been wondering how you could create a second window
You have the main window which shows the game
and then you have the second window with buttons you can press to move the character and do actions
Hello, I’ve been wondering how you could create a second window
You have the main window which shows the game
and then you have the second window with buttons you can press to move the character and do actions
One option would be to create a default Processing window as the main window and use a subclassed PApplet as the second window:
import controlP5.*;
ControlP5 cp5;
GraphicWindow wnd;
float radius = 50;
void slider(float value){
radius = value;
}
void setup() {
size(400,400);
surface.setTitle("Default Window");
background(209);
cp5 = new ControlP5(this);
cp5.addSlider("slider")
.setPosition(width/2 - 150, 100)
.setSize(300,24)
.setRange(0, 500)
.setValue(150)
.setLabelVisible(false)
.setColorBackground(color(255, 255, 255))
.setColorForeground(color(180,180,180))
.setColorActive(color(180,180,180));
;
wnd = new GraphicWindow();
}
void draw() {
}
class GraphicWindow extends PApplet {
public GraphicWindow() {
PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
}
void settings() {
size(600, 600);
}
void setup() {
background(150);
}
void draw() {
background(150);
fill(0,255,0);
circle(width/2,height/2,radius);
}
void mousePressed() {
println("mousePressed in secondary window");
}
}
This works very well, thank you