Jump to content

Multiple Worlds


Recommended Posts

Hi there,

 

I'm deciding on the world design for my game. What I have in mind is multiple "worlds" which have different environments and have different sizes (like <1000x600, keeping the camera the same size 800x600).

 

These worlds will have different object groups of enemies that randomly spawn now and then. The player should be able to "jump/teleport" from environment to environment freely, keeping the state and current objects which were on the screen at the time the same when the player returns.

 

My question is; how is this most efficiently achieved? Should it be with the use of multiple canvas objects? Or is there a way that I can save the current state of the current canvas with all objects on it and reload it at a later time?

 

Any help with be appreciated,

 

Thanks

Link to post
Share on other sites

I think you need to just ensure you store the state of each world properly, and are able to store and retrieve them at will. Try to think in terms of data, not in visual representation - there's no point in using separate canvas instances for this kind of thing as that doesn't help you retrieve the 'state' of the objects on it, just what they looked like.

Link to post
Share on other sites

Does Phaser's API offer any methods that could help to achieve this? Would it have anything to do with the StateManager?

 

The results would end up wiping (removing all elements - including sprites/backgrounds etc.) from the current view of the canvas so it is "blank" and then to load the next state in quick succession for the player to continue in the new state.

Link to post
Share on other sites

There's nothing in Phaser that I'm aware of which will do this as it's pretty implementation-specific, though I have heard that non-volatile states are planned for a future release. Whether that will be specifically what you need is unknown, but I don't see it being too hard to loop through all of your game objects, and store their positions, velocities and any other pertinent information outside of the state, then writing a function to read through that list and recreate the sprites. You'd essentially be implementing a kind of 'save game' system, so tutorials around that mechanic may be handy here.

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.

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...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...