Can't get scene manager to work

I cant seem to get this sketch to display anything. when I remove the this.setup and this.draw functions an image appears but i need it to loop as it does in draw. I’m using scene manager

var pages;
let gui;
let afterFive;
let afterNoon;
let beforeFive

function setup() {
createCanvas(400, 800);
pages = new SceneManager();
gui = createGui();
pages.addScene(Page1);
pages.addScene(Page2);
pages.addScene(Page3);
pages.addScene(Page4);
pages.addScene(Page5);

}

function draw() {
pages.draw();
}

function Page1() {

this.setup = function() {
gui.setTextSize(40);
beforeFive = createButton(“before 5 am”, 75, 250, 250, 60);
afterFive = createButton(“After 5 am”, 75, 380, 250, 60);
afterNoon = createButton(“After 12 pm”, 75, 510, 250, 60);
}
this.draw = function() {
background(220);
drawGui();
textSize(25);
text(‘What time do you plan on ariving?’, 12, 100, 390, 400);
if (afterFive.isPressed) {
print(afterFive.label + " is pressed.");
}
}
}

function Page2() {

}

function Page3() {

}

function Page4() {

}

function Page5() {

}

Hi,

Welcome to the community! :wink:

First of all, you can format your code (to have correct indentations) by using Ctrl+T in the Processing IDE.

Then do you have a function called createGui() and drawGui() ? Because I can’t see it in your program.

I think that the solution might be that you need to write :

// In the setup() function
pages.showScene(Page1);

in order to display your first scene.

That was it! Thank you so much :slight_smile: thank you for the kind introduction. I love this community. :sunny:

2 Likes