Gods Posted March 14, 2015 Report Share Posted March 14, 2015 I am planning a game which will have game modes normal, medium and hard. I plan to change speed and time and maybe some more variables. What is the best way to do this in Phaser? any code examples avaliable with games with multiple modes/difficulty? I thought of some wayshave multiple gamestates easyGame, mediumGame, hardGame and copy the main gamestate files in each one and change the speed and time variables individually. or Have 1 gamestate and have if statementsvar gameMode; if (gameMode=== easy) {var speed =1, time =15;} else if(gameMode===medium){var speed =2, time =10;}else{var speed =3, time =5;} I don't know how I would set the game mode to easy/medium/hard tho here is my setup http://pastebin.com/PKbs6NTi Quote Link to comment Share on other sites More sharing options...
Red Spark Posted March 14, 2015 Report Share Posted March 14, 2015 GameMode.EASY = {speed: 1, time: 15}; GameMode.HARD = {speed: 2, time: 5}; // ...................... var mode = 'EASY'; // or 'HARD' var speed = GameMode[mode].speed; var time = GameMode[mode].time; Pooya72 1 Quote Link to comment Share on other sites More sharing options...
Gods Posted March 15, 2015 Author Report Share Posted March 15, 2015 GameMode.EASY = {speed: 1, time: 15};GameMode.HARD = {speed: 2, time: 5};// ......................var mode = 'EASY'; // or 'HARD'var speed = GameMode[mode].speed;var time = GameMode[mode].time;How would that work in my setup?http://pastebin.com/PKbs6NTi Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.