We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In my game, there are multiple scenes. I want to define different scenes in different classes. I don't want to make the game load everything in the beginning and only load when the scene is loaded. Can I make their own setup() and draw() for those classes? If yes, how can I call those setup() and draw() in the main program? If no, how can I make the code to make the game work as said above?
Answers
this can be achieved easily.
setup and draw are fixed names though, so you need to work around them.
What you do: have a int sceneCount - you'll often see it in the forum as state.
in setup() do only what is done once (size) and everything for scene 0
now in draw use
and go to different functions from here : drawForSceneZero, etc.
once you need to step from scene 0 to 1 you you increase sceneCount by one and call setupForScene1 etc.
unless all keys do the same in all scenes
when you have a startScreen or a helpScreen, these are also scenes (or treated as one)
finally instead of saying scene 0, 1, 2 etc. you can give them names
;-)