protected lastDirectionX lastDirection; // The last direction #endregion Fields #region Constructors /// <summary> /// Constructor /// </summary> /// <param name="game">Instance of base game</param> /// <param name="position">Position</param> /// <param name="gravity">The gravity that shal be applyed</param> public Character(Game game, World world, Vector2 position) : base(game, world, position) { size = new Point(75, 75); animData = new AnimationData(); inAir = false; lastDirection = lastDirectionX.RIGHT; inGoal = false; }
protected lastDirectionX lastDirection; // The last direction #endregion Fields #region Constructors /// <summary> /// Constructor /// </summary> /// <param name="game">Instance of base game</param> /// <param name="position">Position</param> /// <param name="gravity">The gravity that shal be applyed</param> public Character(Game game, Point position, Vector2 gravity) : base(game, position) { this.gravity = gravity; collisionManager.RegisterObject(this); // Add this character to collision's list. size = new Point(75, 75); animData = new AnimationData(); inAir = false; lastDirection = lastDirectionX.RIGHT; inGoal = false; }
/// <summary> /// Save last direction of player /// </summary> public void SaveLastDirection() { if (velocity.X > 0.0f) { lastDirection = lastDirectionX.RIGHT; } else if (velocity.X < 0.0f) { lastDirection = lastDirectionX.LEFT; } }