Mrblah Posted February 15, 2018 Share Posted February 15, 2018 i don't know what the code is to start a new level after collecting ll items. Link to comment Share on other sites More sharing options...
mickeyren Posted February 15, 2018 Share Posted February 15, 2018 depending on how you are creating your levels, you could have a function "initLevel(level)" where you pass the current level that your player is in. inside the function you would have things: - that destroys that current tilemap if it exists and initializes a new one. - restores max health for the player - places the items on the tilemap basically resets/sets a bunch of stuff depending on your game mechanics. Link to comment Share on other sites More sharing options...
Mrblah Posted February 24, 2018 Author Share Posted February 24, 2018 Thanks, but i was actually looking to reset the current level and after gathering all items as in: all items and player placement. Link to comment Share on other sites More sharing options...
casey Posted February 24, 2018 Share Posted February 24, 2018 10 hours ago, Mrblah said: Thanks, but i was actually looking to reset the current level and after gathering all items as in: all items and player placement. Not quite sure what you mean. Do you mean just how to store the items in a variable, or how to use restart? Check out the Space Invaders example: http://phaser.io/examples/v2/games/invaders Link to comment Share on other sites More sharing options...
Adel Posted February 26, 2018 Share Posted February 26, 2018 /** * GameState * @constructor */ App.Game = function () { 'use strict'; Phaser.State.call(this); this.__player = {}; }; /** @type {Phaser.State} */ App.Game.prototype = Object.create(Phaser.State.prototype); /** @type {App.Game|*} */ App.Game.prototype.constructor = App.Game; Once a state is instantiated, all properties declared in the state constructor persists after restarting it. Same if those properties are declared in the global scope, global means they are properties of the window object. Link to comment Share on other sites More sharing options...
Recommended Posts