public void DrawMap(SpriteBatch spriteBatch) { if (_tileSetTextureIsDirty) { TileSetTexture = ContentCacheManager.GetTexture(TileSetTexturePath); TileSheet = new AnimationSheet(TileSetTexture, TileSize, TileSize); // add the animations for (int frame = 0; frame < TileSheet.TotalFrames; frame++) { TileSheet.Add(frame, 1f, false, frame); } } if (TileSetTexture != null) { MapData.EachCell((cell, tile) => { // adjust the vector position according to the tilesize cell *= TileSize; // only draw tiles that have data if (tile > -1) { TileSheet[tile].Draw(spriteBatch, cell, Color.White * Opacity); } if (DrawGrid) { var frame = new Rectangle((int)cell.X, (int)cell.Y, TileSize, TileSize); var whiteTexture = new Texture2D(spriteBatch.GraphicsDevice, 1, 1); whiteTexture.SetData(new Color[] { Color.White }); spriteBatch.Draw(whiteTexture, new Rectangle(frame.Left, frame.Top, frame.Width, 1), Color.White); spriteBatch.Draw(whiteTexture, new Rectangle(frame.Left, frame.Bottom, frame.Width, 1), Color.White); spriteBatch.Draw(whiteTexture, new Rectangle(frame.Left, frame.Top, 1, frame.Height), Color.White); spriteBatch.Draw(whiteTexture, new Rectangle(frame.Right, frame.Top, 1, frame.Height + 1), Color.White); } }); } }
/// <summary> /// Load your graphics content. /// </summary> protected override void LoadContent() { // Load content belonging to the screen manager. _spriteBatch = new SpriteBatch(GraphicsDevice); _font = ContentCacheManager.GetFont("Fonts/MenuFont"); _blankTexture = ContentCacheManager.GetTexture("FragEngine.Resources.blank.png"); // Tell each of the screens to load their content. foreach (GameScreenBase screen in screens) { screen.LoadContent(); } // update the title-safe area _titleSafeArea = new Rectangle( (int)Math.Floor(GraphicsDevice.Viewport.X + GraphicsDevice.Viewport.Width * 0.05f), (int)Math.Floor(GraphicsDevice.Viewport.Y + GraphicsDevice.Viewport.Height * 0.05f), (int)Math.Floor(GraphicsDevice.Viewport.Width * 0.9f), (int)Math.Floor(GraphicsDevice.Viewport.Height * 0.9f)); }
public AnimationSheet(string texturePath, int frameWidth, int frameHeight) : this(frameWidth, frameHeight) { _texturePath = texturePath; SpriteSheet = ContentCacheManager.GetTexture(texturePath); }
public override void LoadContent() { _logoTexture = ContentCacheManager.GetTexture(_texturePath); base.LoadContent(); }