Platformer.Player.Reset C# (CSharp) Method

Reset() public method

Resets the player to life.
public Reset ( Vector2 position ) : void
position Vector2 The position to come to life at.
return void
        public void Reset(Vector2 position)
        {
            Position = position;
            lastGroundPos = position;
            Velocity = Vector2.Zero;
            isAlive = true;
            deathPlayed = false;
            isRight = true;
            sprite.PlayAnimation(idleRightAnimation);
        }

Usage Example

Example #1
0
        public void StartNewLife(Player player, bool isKilled)
        {
            float xpos = camera.GetSpawnPoint(game.ScreenManager.GraphicsDevice.Viewport);

            if (isKilled)
            {
                SpawnCorpse(player.Position, player.Flip, PlatformerGame.Players.IndexOf(player));
            }
            if (xpos > 0.0f)
            {
                //player.IsRespawnable = true;
                float ypos = -0.0f;
                player.Reset(new Vector2(xpos, ypos));
            }
            //else if (xpos == -999.9f)
            //{
            //player.IsRespawnable = false;
            //    player.Reset(new Vector2(xpos, 0.0f));
            //}
        }
All Usage Examples Of Platformer.Player::Reset