Is there any way to make something like a “launcher” in processing. What I mean by that is basically a main menu and when you click a button, it closes itself and opens another .exe file (or runs a processing source code which would be better).
1 Like
You can try using launch()
or exec()
. I have attached other posts that are relevant.
Kf
- https://processing.org/reference/launch_.html
- https://stackoverflow.com/questions/13991007/execute-external-program-in-java
- https://forum.processing.org/two/discussion/20568/how-do-i-launch-a-compiled-sketch-from-within-another-sketch
- https://forum.processing.org/two/discussion/26485/launch-won-t-launch-my-compiled-processing-sketch
- How do i get the output of a command?
4 Likes
Thanks! I’ll take a look.
Thanks again!
The solution here worked:
I made it so it launches when I click a button but it launches my application 2-5 times depending on how long the mouse stays on the button after clicking. It looks like it is a problem with my button. Here is my full code:
//PFont zigBlack;
int b1f = 140;
int b2f = 140;
int b3f = 140;
int b4f = 140;
int v1f = 200;
boolean versions = false;
boolean credits = false;
boolean controls = false;
void setup() {
size(1200,600);
//zigBlack = createFont("Minecraftia 2.0", 32);
//textFont(zigBlack);
frameRate(60);
smooth();
}
void draw() {
background(217,125,4);
fill(0,140);
rect(35,0,320,600);
fill(255);
textSize(45);
text("The",400,105);
text("Dungeons",400,160);
text("Of The West",400,220);
textSize(15);
text("tDotW Launcher 1.0",1020,600);
fill(0,b1f);
rect(400,225,350,70);
fill(0,b2f);
rect(400,315,350,70);
fill(0,b3f);
rect(400,405,350,70);
fill(0,b4f);
rect(400,495,350,70);
fill(255);
textSize(25);
text("Launch Game",420,286);
text("Controls",420,376);
text("Credits",420,466);
text("Quit Launcher",420,556);
if (versions == true) {
fill(0,140);
rect(800,0,360,600);
fill(0,200);
rect(800,0,360,30);
fill(0,v1f);
rect(800,45,360,100);
fill(255);
textSize(25);
text("Version 1.0",810,93);
textSize(15);
text("Release Date: N/A",810,110);
fill(255);
textSize(15);
text("Select a version",808,32);
}
if (controls == true) {
fill(0,140);
rect(800,0,360,600);
fill(0,200);
rect(800,0,360,30);
fill(255);
textSize(15);
text("Controls",808,32);
}
if (credits == true) {
fill(0,140);
rect(800,0,360,600);
fill(0,200);
rect(800,0,360,30);
fill(255);
textSize(15);
text("Credits",808,32);
}
if(mousePressed && mouseX>800 && mouseX<1160 && mouseY>45 && mouseY<145) {
PrintWriter output=null;
output = createWriter("myfile.bat");
output.println("cd C:/Users/Lenovo/Desktop/Dungeon_Game/application.windows64/");
output.println("start Dungeon_Game.exe");
output.flush();
output.close();
output=null;
launch(sketchPath("")+"myfile.bat");
}
if(versions == true && mouseX>800 && mouseX<1160 && mouseY>45 && mouseY<145) {
v1f = 140;
} else{
v1f = 200;
}
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>225 && mouseY<295) versions = true;
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>225 && mouseY<295 && credits == true) {
credits = false;
versions = true;
}
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>225 && mouseY<295 && controls == true) {
controls = false;
versions = true;
}
if(mouseX>400 && mouseX<750 && mouseY>225 && mouseY<295) {
b1f = 200;
} else{
b1f = 140;
}
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>315 && mouseY<385) controls = true;
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>315 && mouseY<385 && versions == true) {
controls = true;
versions = false;
}
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>315 && mouseY<385 && credits == true) {
controls = true;
credits = false;
}
if(mouseX>400 && mouseX<750 && mouseY>315 && mouseY<385) {
b2f = 200;
} else{
b2f = 140;
}
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>405 && mouseY<475) credits = true;
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>405 && mouseY<475 && versions == true) {
credits = true;
versions = false;
}
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>405 && mouseY<475 && controls == true) {
credits = true;
controls = false;
}
if(mouseX>400 && mouseX<750 && mouseY>405 && mouseY<475) {
b3f = 200;
} else{
b3f = 140;
}
if(mousePressed && mouseX>400 && mouseX<750 && mouseY>495 && mouseY<565) exit();
if(mouseX>400 && mouseX<750 && mouseY>495 && mouseY<565) {
b4f = 200;
} else{
b4f = 140;
}
}
The “Version 1.0” button launches it (it appears when clicked on “Launch Game”). How can I fix this?
EDIT: Fixed it, my dumbness. Instead of if(mousePressed &&), I created a mouseClicked() void and put the stuff under that.
1 Like