Sign in to follow this  
Mrblah

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.

Share this post


Link to post
Share on other sites
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 

Share this post


Link to post
Share on other sites
/**
 * 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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.