Sign in to follow this  

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: 

Share this post

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

Share this post

Link to post
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.