1 decade ago by DaveVoyles
How can I store the player's location during death, so that I can respawn the player at that location, instead of from the beginning of the level again? I'm crafting a side-scrolling 2d shmup if that helps to give you a better idea.
I'm grabbing my player's current location and storing it in the update function for ig.game like so:
update: function (){
....
// Grab player's current location
var player = this.getEntitiesByType(EntityPlayer);
this.playerRestartPOS = this.player.pos;
console.log(this.player.pos);
....
}
Now obviously the player dies, and this returns to 0,0 because there is no player to access. How can I store the location just BEFORE the player died?
I want to take that, pass it back to the player, and have it restart at that point.
I'm grabbing my player's current location and storing it in the update function for ig.game like so:
update: function (){
....
// Grab player's current location
var player = this.getEntitiesByType(EntityPlayer);
this.playerRestartPOS = this.player.pos;
console.log(this.player.pos);
....
}
Now obviously the player dies, and this returns to 0,0 because there is no player to access. How can I store the location just BEFORE the player died?
I want to take that, pass it back to the player, and have it restart at that point.