/// <summary> /// Constructor /// </summary> /// <param name="level">The level containing the player</param> /// <param name="name">Name of the Player</param> /// <param name="texture">For the base constructor</param> /// <param name="frameCount">For the animation</param> /// <param name="framesPerSec">For the animation speed</param> public Player(LevelScreen level, String name, Texture2D texture, int frameCount, int framesPerSec) : base(name, texture, frameCount, framesPerSec) { // Should be put in a LoadContent method ? walkAnimation = level.ContentManager.Load<Texture2D>(@"images/player/walk"); idleAnimation = level.ContentManager.Load<Texture2D>(@"images/player/idle1"); jumpAnimation = level.ContentManager.Load<Texture2D>(@"images/player/jump"); fallAnimation = level.ContentManager.Load<Texture2D>(@"images/player/fall"); jumpSmokeAnimation = level.ContentManager.Load<Texture2D>(@"smokes"); _level = level; // Very ugly way to kill the sprite when finished, and initialize it ... _smoke = (AnimatedSprite)_level.BackSpriteManager.CreateSprite(new AnimatedSprite("smoke", jumpSmokeAnimation, 10, 20)); _smoke.Visible = false; _smoke.PlayOnce = true; _smoke.Pause(); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { gameFont = Game.Content.Load<SpriteFont>("gamefont"); Texture2D hbarTexture = Game.Content.Load<Texture2D>("hbar"); _spawner = new Spawner(Game.Content, ScreenManager.SpriteBatch); _healthBar = new HealthBar(hbarTexture, ScreenManager.SpriteBatch); _level = new LevelScreen(_spawner, _backSpriteManager, _midSpriteManager, _frontSpriteManager); _level.ScreenManager = this.ScreenManager; _level.ControllingPlayer = this.ControllingPlayer; _level.LoadContent(); _level.Initialize(); _audioManager.PlaySong("loop"); // A real game would probably have more content than this sample, so // it would take longer to load. We simulate that by delaying for a // while, giving you a chance to admire the beautiful loading screen. Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. Game.ResetElapsedTime(); }