Go to current scene before player death?

How would I go to the current scene that I was on before my player died?

Any help as always is GREATLY appreciated!

Thank You! <3

There’s multiple ways to achieve this though it depends on your setup.

I would imagine you are calling a game over scene or something and want to return to the last scene you were on.

One way of doing this is passing a scene key to your game over scene and retrieving the data in the init method then switching back to that scene.

See here for an example on how to send data from one scene to another: http://labs.phaser.io/edit.html?src=src\scenes\passing%20data%20to%20a%20scene.js

I don’t understand this. How can I have unlimited levels & have the player go to the last one before death?

// Level22Scene.js
this.scene.start('gameover', { previousScene: 'Level22' });

// GameOverScene.js
init(data){
this.previousScene = data.previousScene;
}

Then use this.previousScene to navigate back to the scene whenever you like.

Does that make sense for your current workflow?

@Phailser : This is my GameOverScene.js :

var GameoverWindow = new Phaser.Class

({

	Extends : Phaser.Scene, 

	initialize : 

	function GameoverWindow ( ) {

		Phaser.Scene.call ( this, {

			key : 'GameoverWindow', 
			active : false, 

		} );

	}, 

	__animComplete : function ( __scene, __camera, __entity, __time ) {

		// Create Object Layer{s}

		this.GameData = new GameData ( );

		__time.delayedCall (
			1000, function ( __anim, __scene ) {
				// Transition to `move` state
				__stateMachine.transition ( 'move' );
				__entity.setVelocityX ( __PLAYER_MAX_MOVESPEED );
				__time.delayedCall (
					3000, function ( __anim, __scene ) {
						GameData.stopCameraFollow ( {
							camera : __camera, 
							entity : __entity, 
						}, 1 );
						__time.delayedCall (
							3000, function ( __anim, __scene ) {
								__scene.scene.start ( 'TitleScene', { previousScene: 'TitleScene' } );
							}, [ GetAnimName ( __entity ), __scene ]
						);
					}, [ GetAnimName ( __entity ), __scene ]
				);
			}, [ GetAnimName ( __entity ), __scene ]
		);

	}, 

	__activateRevive : function ( __objData ) {

		__animAction = __objData.animAction;
		__scene = __objData.scene;
		__camera = __objData.camera;
		__entity = __objData.entity;
		__time = __objData.time;

		__stateMachine.transition ( __animAction );

		__entity.on ( 'animationcomplete-' + __animAction, function ( ) {
			__animComplete ( __scene, __camera, __entity, __time );
		} );

	}, 

	__initializeWindow : function ( __objData ) {

		__scene = __objData.scene;
		__camera = __objData.camera;
		__entity = __objData.entity;
		__time = __objData.time;
		__status = __objData.status;

		if ( typeof ( $ ) !== null ) {

			$ ( '<div></div>' ).appendTo ( 'body' )

			.html ( '<div><h6>Would you like to try again?</h6></div>' )

			.dialog ({

				modal : true, title : 'Play Again?', zIndex : 10000, 
				autoOpen : true, width : 300, height : 250, resizable : false, 
				show : 'fade', hide : 'fade', 

				buttons : {

					Yes : function ( ) {

						$ ( this ).dialog ( 'close' );

						this.__activateRevive ({
							animAction : 'revive', 
							scene : __scene, 
							camera : __camera, 
							entity : __entity, 
							time : __time, 
						});

					}, 

					No : function ( ) {

						$ ( this ).dialog ( 'close' );

						$ ( '<div></div>' ).appendTo ( 'body' )

						.html ( '<div><h6>Are you sure?</h6></div>' )

						.dialog ({

							modal : true, title : 'Play Again?', zIndex : 10000, 
							autoOpen : true, width : 300, height : 250, resizable : false, 
							show : 'fade', hide : 'fade', 

							buttons : {

								Yes : function ( ) {

									$ ( this ).remove ( );
									
								}, 

								No : function ( ) {

									$ ( this ).dialog ( 'close' );

									__stateMachine.transition ( 'death' );

								}, 

							}, 

							close : function ( event, ui ) {

								$ ( this ).remove ( );

							}

						});

					}, 
					
				}, 

				close : function ( event, ui ) {

					$ ( this ).remove ( );

				}

			});

		}

		else {

			alert ( 'Please install JQuery & JQuery UI & try again!' );

			return;

		}

	}, 

	init : function ( data ) {

		console.log ( 'init', data );
		this.finalScore = data.score;

	}, 

});

@Phailser : Where do I put it?

Someone can help??