Heppell08 Posted February 5, 2014 Share Posted February 5, 2014 If i have in my main menu a button, that button begins the game state, the game then begins without issue. My issue is that i want to change a number externally from game. Mainly the difficulty selection.This is the only part of my code im battling with and i've scoured the net for examples and answers but cant seem to find a straight forward answer. I've looked in phaser for help but still not finding an answer.Basically i want to OOP code a global variable, a number. I press button in one state 'Menu' then when game state starts the number i selected 'Difficulty' is changed in the game state to accommodate my needs.Maybe i'm doing this wrong i have no idea at all. Maybe i need to make something a bit more complex, a bit more simple i have no idea. Link to comment Share on other sites More sharing options...
Heppell08 Posted February 5, 2014 Author Share Posted February 5, 2014 Ok i figured it out. I placed the difficulty and the number in the button function like so:startGame: function (pointer) { console.log('lets play'); this.game.difficulty = 10; this.game.state.start('Game'); }then declared the variable of difficulty in my game without referencing a number or string to it. Simply put it, i did this: var difficulty; Heppell08 1 Link to comment Share on other sites More sharing options...
Recommended Posts