|
Written by Jeff Brown
|
Adding checkpoints to Platform Starter Kit
The way this works is by adding a tile to use in your text files and when you touch the tile it becomes your new respawn point. This works the same way as the checkpoints in the Sonic games.
In Tile.cs add the following in enum TileCollision:
in Level.cs After this line:
Add this:
public Vector2 checkpoint;
Now find the following:
public void StartNewLife() { Player.Reset(start); }
And change it to this:
public void StartNewLife() { if(checkpoint != Vector2.Zero) Player.Reset(checkpoint); else Player.Reset(start); }
In ‘private Tile LoadTile(...)’ add this near the others.
//Checkpoint case 'P': return LoadTile("BlockA0", TileCollision.Checkpoint);
Now in Player.cs find the following:
TileCollision collision = Level.GetCollision(x, y);
And add this after it:
if (collision == TileCollision.Checkpoint) Level.checkpoint = RectangleExtensions.GetBottomCenter(BoundingRectangle);
|
i want to take it another step forward though
and add it just to a prop i.e: just another object instead of a tile.How would i go about doing that?