assafsahar123 Posted November 18, 2015 Share Posted November 18, 2015 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 More sharing options...
rich Posted November 18, 2015 Share Posted November 18, 2015 The short answer is: no. Phaser 2 has no support for this, you would need to implement it yourself. webcaetano and assafsahar123 2 Link to comment Share on other sites More sharing options...
webcaetano Posted November 18, 2015 Share Posted November 18, 2015 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 anotherAlready tested this in a sprite preview panel. But as @rich mentioned you can't have simultaneous states in one canvas assafsahar123 1 Link to comment Share on other sites More sharing options...
assafsahar123 Posted November 18, 2015 Author Share Posted November 18, 2015 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... Link to comment Share on other sites More sharing options...
webcaetano Posted November 18, 2015 Share Posted November 18, 2015 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 assafsahar123 1 Link to comment Share on other sites More sharing options...
assafsahar123 Posted November 18, 2015 Author Share Posted November 18, 2015 That sounds interesting. I don't need the animation to continue, but I need to save data from states and use it for the next one. I assume this is possible. right?Also, how do I take screenshot of the canvas? is it something that can be done with phaser? Link to comment Share on other sites More sharing options...
pog Posted November 18, 2015 Share Posted November 18, 2015 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-1http://phaser.io/examples/v2/sprites/extending-sprite-demo-2 assafsahar123 1 Link to comment Share on other sites More sharing options...
Recommended Posts