Jump to content

Keep objects between states


Recommended Posts

Hello again,

I am looking for a way to keep an object between all states.


I found this topic: http://www.html5gamedevs.com/topic/4180-is-there-a-way-to-keep-some-objects-beetween-states/

This seems to clear nothing and then you have to clear everything but the things you want.


Is there a way to pass maybe an array of objects to keep, while everyting else is destroyed?


I have tried the suggestion to destroy stuff manually, but in the example below: 

window.onload = function() {        var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, '', { preload: preload, create: create, update:update });        function preload() {        }        function create() {            fadeLayer = game.add.group();            gameLayer = game.add.group();            fadeLayer.z = 1000;            game.fader = game.add.graphics(0, 0);            game.fader.beginFill(0xffcc00);            game.fader.drawRect(0, 0, window.innerWidth, window.innerHeight);            game.fader.alpha = 1;            game.fader.endFill();            fadeLayer.add(game.fader);            game.menu = function(){}            game.menu.prototype = {                preload: function(){},                create : function(){}            }            game.add.tween(game.fader).to({alpha:0}, 500).start();            game.state.add('menu', game.menu);            game.state.start('menu', false);        }        function update() {        }         }

The tween does not execute anymore unless I remove the game.start.state('menu', false) line.

I think it would be great to have more examples and explanations, once I get my head around it all I will make some to share.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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