public Player(ContentManager content) { _content = content; Texture = content.Load<Texture2D>("Player"); Dictionary<string, Rectangle> spriteMap = content.Load<Dictionary<string, Rectangle>>("PlayerSpriteMap"); animation = new Animation(Texture, spriteMap); animationPlayer.PlayAnimation(animation, "PlayerForward", 0.3f, true); Health = 5; }
///// <summary> ///// Gets a texture origin at the bottom center of each frame. ///// </summary> //public Vector2 Origin //{ // get { return new Vector2(Animation.FrameWidth / 2.0f, Animation.FrameHeight); } //} /// <summary> /// Begins or continues playback of an animation. /// </summary> public void PlayAnimation(Animation animation, string animationName, float frameTime, bool isLooping) { // If this animation is already running, do not restart it. if (previousAnimationName == animationName) { if (Animation.Name == animation.Name) return; } animation.SetAnimation(animationName, frameTime, isLooping); oneTimeLoopComplete = false; // Start the new animation. this.animation = animation; this.frameIndex = 0; this.time = 0.0f; this.currentFrame = animation.Name + "-0"; previousAnimationName = animation.Name; }