Jump to content

multiple states showing at the same time


assafsahar123
 Share

Recommended Posts

Hi,

I'm using the Phaser framework to develop a game and I was wondering if it's possible to create multiple states that exist together. The effect I want to get is this:
There are several game screens. 
The player does something in the first screen, then clicks a button to move to the next screen. 
I want the first screen to slide out to the left side while at the same time the next screen slides in from the right side. 
This effect will happen again for each new screen.
Also, it will be possible to page backwards to previous screens with the same effect, just reversed.
As far as I understand when starting a new state, the previous one gets destroyed, so I don't see how to use the state system for the desired effect.

Thanks for your help!

Link to comment
Share on other sites

Hi,

I'm using the Phaser framework to develop a game and I was wondering if it's possible to create multiple states that exist together. The effect I want to get is this:

There are several game screens. 

The player does something in the first screen, then clicks a button to move to the next screen. 

I want the first screen to slide out to the left side while at the same time the next screen slides in from the right side. 

This effect will happen again for each new screen.

Also, it will be possible to page backwards to previous screens with the same effect, just reversed.

As far as I understand when starting a new state, the previous one gets destroyed, so I don't see how to use the state system for the desired effect.

Thanks for your help!

Use multi canvas. 

One state in each.

Slide the canvas.

You can use sprites loaded from one canvas game in another

Already tested this in a sprite preview panel. 

 

But as @rich mentioned you can't have simultaneous states in one canvas

Link to comment
Share on other sites

Thanks both, I'll give a try to multi canvas although I'm not sure how efficient it is if I have let's say 5 or 6 screens working at the same time...

 

You can create and delete the canvas, destroy the game,  etc.

Anytime

 

Other thing tricky you can do is... take a screen shot of the canvas before change to other state , and use it to kinda "pretend" the slide 

But the animations will stop

Link to comment
Share on other sites

To use data between different states put it in a global variable so the player data might be something like this:

var player = {    world: {        x: 100, y: 150    },    weapon: {        name: 'BFG 9000',        ammo: 10    }};

You can also make your sprite pools global or use global extended sprites

 

http://phaser.io/examples/v2/sprites/extending-sprite-demo-1

http://phaser.io/examples/v2/sprites/extending-sprite-demo-2

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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