black_c Posted April 18, 2017 Share Posted April 18, 2017 When the player passes through the checkpoint, the player's coordinates are saved. When a player falls into a trap, the level is restarted and the player appears at the location of the checkpoint. Link to comment Share on other sites More sharing options...
snowbillr Posted April 18, 2017 Share Posted April 18, 2017 I'd make a Checkpoint class and a CheckpointStore class, then whenever the player passes through a checkpoint in the game make a new Checkpoint and put it in the CheckpointStore. When the player falls in to a trap and dies, ask the CheckpointStore for the last saved Checkpoint and restore the player and gamestate to what's saved in that Checkpoint. Obviously there is a lot more detail necessary for this approach, but that's a high level way to look at it. (Also the term "store" here I'm using by the definition of "a place to keep something" rather than "a place to buy something") Link to comment Share on other sites More sharing options...
black_c Posted April 18, 2017 Author Share Posted April 18, 2017 How to get player's coordinates? Link to comment Share on other sites More sharing options...
snowbillr Posted April 18, 2017 Share Posted April 18, 2017 It seems like you should take a look at Phaser's documentation and some of its examples. There's a level of fundamentals that you need to understand in Phaser before you're going to have any success with it. Something like finding a players' coordinates can be looked up in the documentation or the examples, and looking that up yourself will build your skills in both Phaser and finding the answers to your Phaser questions. I'm not trying to discourage you from asking questions on the forum - the Checkpoint question was a fantastic one! There's all kinds of ways to implement it and there's a great discussion to be had in the forums about it. But when it comes to the basics of Phaser or any library or framework really, you're better off attempting to look up the documentation or googling around to answer your question first rather than asking for help too soon. Link to comment Share on other sites More sharing options...
black_c Posted April 19, 2017 Author Share Posted April 19, 2017 You can give a link to the method that I need? I can't find. Link to comment Share on other sites More sharing options...
snowbillr Posted April 19, 2017 Share Posted April 19, 2017 Sure. I'm assuming your player object is a Phaser.Sprite. In this example https://phaser.io/examples/v2/sprites/move-a-sprite the update method accesses the sprite's 'x' and 'y' properties, which represent the sprite's location. black_c 1 Link to comment Share on other sites More sharing options...
Recommended Posts