/// <summary> /// Method to play an animation /// </summary> /// <param name="textureHandler">Animation handler</param> public void Play(TextureHandler textureHandler) { if (this.TextureHandler == textureHandler) { return; } this.textureHandler = textureHandler; index = 0; time = 0.0f; }
/// <summary> /// method to load content of the player class /// </summary> public void LoadContent() { idleAnimation = new TextureHandler(Level.Content.Load <Texture2D>("sprites/player/idle"), 0.1f, true); runAnimation = new TextureHandler(Level.Content.Load <Texture2D>("sprites/player/run"), 0.1f, true); jumpAnimation = new TextureHandler(Level.Content.Load <Texture2D>("sprites/player/jump"), 0.1f, false); celebrateAnimation = new TextureHandler(Level.Content.Load <Texture2D>("sprites/player/celeb"), 0.1f, false); jumpSound = Level.Content.Load <SoundEffect>("sounds/jumpSound"); int width = (int)(idleAnimation.Width * 0.4); int left = (idleAnimation.Width - width) / 2; int height = (int)(idleAnimation.Height * 0.8); int top = idleAnimation.Height - height; bounds = new Rectangle(left, top, width, height); }