Jump to content

state restart, group problem


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

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.


  • Recently Browsing   0 members

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