Jump to content

Subsequent loads of a state do not work?


seiyria
 Share

Recommended Posts

So my game follows a format such that there is a menu you choose stages from, load them, complete them, and you go back to the main menu. You can see my main menu state code here, with a menu before loading here, and after completing a stage here.

 

The way I handle finishing a level is in my play gamestates update function, shown here: 

		@game.physics.overlap @game.player.ref, @warps, (player, warp) =>			if warp.offX is 0 and warp.offY is 0				@finishLevel()			else				@game.player.ref.x = warp.x + warp.offX				@game.player.ref.y = warp.y + warp.offY
#here's the function that is called abovefinishLevel: () ->    @game.state.start 'MainMenu' 

(if the particular object does not have anywhere to go, it simply finishes the level)

 

I am not sure if I'm doing this incorrectly, but I must be because I get a blank menu after finishing a level. I have verified that MainMenu.preload() and MainMenu.create() are both being called, and the MainMenu.buttons array is being populated in both cases as well. Just, nothing displays.

Link to comment
Share on other sites

You seem to be doing it correctly, try calling 

@game.state.start 'MainMenu', false, true

(not sure if that is correctly written in whatever language you are using) but basically, when you call the mainmenu state send a false and a true respectively.

 

If i am not mistaken the first boolean is to clear the cache (if true) and the second boolean clears the world (if true). It's a wild guess but give it a shot

Link to comment
Share on other sites

You seem to be doing it correctly, try calling 

@game.state.start 'MainMenu', false, true

(not sure if that is correctly written in whatever language you are using) but basically, when you call the mainmenu state send a false and a true respectively.

 

If i am not mistaken the first boolean is to clear the cache (if true) and the second boolean clears the world (if true). It's a wild guess but give it a shot

The arguments are actually the other way around (true, false is implied so I exclude them). It does the same thing unfortunately.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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