I wanted to have a symple dialogue system for my game but I don’t know how to make the first text appear on click and then the next piece of text if you click again.
int scene = 1;
void setup() {
size(800, 600);
}
void draw() {
if (scene == 1) {
Scene1();
} else if (scene == 2) {
Scene2();
}
}
boolean isPointInRectangle(float px, float py, float rx, float ry, float rw, float rh) {
if (px >= rx &&
px <= rx + rw &&
py >= ry &&
py <= ry + rh) {
return true;
}
return false;
}
void Scene1() {
background(255, 0, 0);
//drawing the text bubble
stroke(0);
fill(255);
ellipse(300, 180, 300, 100);
triangle(220, 220, 300, 220, 170, 300);
noStroke();
rect(220, 220, 100, 10);
//end of text bubble
//drawing the arrow only when the text is finished
if (message1 == true) {
fill(0);
triangle(750, 300, 750, 340, 790, 320);
}
//end of the arrow
if (mousePressed & isPointInRectangle(mouseX, mouseY, 750, 300, 40, 40)) {
scene = scene + 1; // if you click on the triangle on the screen you go to the next scene
}
if (message1 == true) {
textSize(19); //test dialogue for now. If you press the mouse there is dialogue
fill(0);
text("This is test scene1", 220, 190);
}
fill(0);
textSize(19);
text("Click on the screen", 300, 590);
}
boolean message1 = false;
void mousePressed() {
message1 = true;
}