icetimux Posted April 20, 2017 Share Posted April 20, 2017 Hi everyone. I have experience with phaser making small arcade like games. But I now want to make a larger platformer with worlds. I cant figure out how to organise my code for each world and how to switch between worlds. Can anyone provide me with some guidance on how I can do this? Link to comment Share on other sites More sharing options...
MikeW Posted April 20, 2017 Share Posted April 20, 2017 You are going to need stages. When you end one world - call a stage that sets up the data for the gameplay stage, and then calls the gamestage who's create function build the world currently loaded for it. But I am new at phaser and just cause it works does not make it the best way. Link to comment Share on other sites More sharing options...
Cudabear Posted April 20, 2017 Share Posted April 20, 2017 What I typically do is have a game state that corresponds to your main gameplay loop, IE when your user is actually playing the game. Then, I feed this gameplay state a data object that represents the level that the player will be playing on, with information such as where the character spawns, where the goal object(s) spawn, where enemies spawn, gameplay triggers, ect. The main loop can parse out this data and actually calculate the logic on the fly. This way, you create degrees of separation between your gameplay logic and the data that represents your "worlds" and it'll be much easier to add more worlds or change mechanics later. Then, when it comes time to switch to a new world, you just have to restart the state again with a new "world" data object. snowbillr 1 Link to comment Share on other sites More sharing options...
ruddles Posted April 20, 2017 Share Posted April 20, 2017 Might be worth having a look at the tutorial at https://hacks.mozilla.org/2017/04/html5-games-workshop-make-a-platformer-game-with-javascript/ as it creates a simple platformer with multiple levels. It's not perfect but it would potentially be a good starting point. Link to comment Share on other sites More sharing options...
Recommended Posts