Jump to content

state restart, group problem


nak3ddogs
 Share

Recommended Posts

Hi! pls help with state restart. 

i wanna switch back from game to main menu.

after the switchback the groups of mainmenu are not exists.

 

this.game.game.state.start('MainMenu', true, false);

 

     this.menu_group = this.add.group();        this.menu_group.add(this.bg_popup);        this.menu_group.x = this.world.centerX;        this.menu_group.y = this.world.centerY-10;        this.add.tween(this.menu_group).to({y:this.world.centerY+10}, 2000, Phaser.Easing.Quadratic.InOut, true, 0, 10000, true);                this.menu_items_group = this.add.group();        this.menu_group.add(this.menu_items_group);        this.alap_group = this.add.group();        this.options_group = this.add.group();        this.credits_group = this.add.group();        this.menu_items_group.add(this.alap_group);        this.menu_items_group.add(this.options_group);        this.menu_items_group.add(this.credits_group);

ty for any advice

 

Link to comment
Share on other sites

okey i solved but it is not a nice solution.
i made a global var(mainmenuhelper = false)
 

at the mainmenu create function's start i check

if (mainMenuHelpBoolean == true) {            mainMenuHelpBoolean = false;            console.log(mainMenuHelpBoolean)            this.state.restart(); };

and when i want to go back to main menu i use the global var

 

if (this.life <= 0) {                    mainMenuHelpBoolean = true;                    this.game.game.state.start('MainMenu', false, false);  };

and now the groups are work

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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