Jump to content

Help with new level (Newbie)


Recommended Posts

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

  • 2 weeks later...
 * GameState
 * @constructor
App.Game = function () {
    'use strict';

    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


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...