I want to add a title screen to my game, where you will have to press Enter before the game starts. How would I go about doing this?
You would want to break your game scene out of your main Javascript file first. Then you can create other scenes and switch between them with this.scene.start(‘NameOfScene’). Then you can have a TitleScene or something like that where you can display your title image and listen for the Enter key before starting your game scene.
Maybe check out this YouTube video for more info about scenes.
You can also check the sources of Enclave Phaser Template on GitHub - it does exactly that: you can move to the next state from the main menu by hitting Enter.
I prefer to display the title screen in html - so it is up before any javascript and asset loads.
You can do it that way as well. But it can be a little bit more convenient to have it all in your game code, particularly if you are going to port your game to any other platforms since you can keep it all under the control of Phaser’s scaling functionality versus needing to handle part of your scaling in HTML and the other part in the game.
@Jackolantern Yep good points, but ff you are comfy with css those issues are minor… and there is the minor feature that your html title screen text is visible to crawlers (ie: can be found through google search) but of curse there are plenty of workarounds for that.