public override void Render(float deltaTime) { base.Render(deltaTime); _tiledMap.Draw(Game.Camera); _spriteBatch.Begin(Game.Camera.GetViewMatrix()); for (int y = 0; y < _tiledMap.Height; y++) { for (int x = 0; x < _tiledMap.Width; x++) { var tileInfo = _tiledMap.GetTileAt(1, x, y); var text = tileInfo.Id.ToString(); var tx = (int)tileInfo.Centre.X; var ty = (int)tileInfo.Centre.Y; var rectangle = _font.MeasureText(text, tx, ty); var color = new Color(Color.Black, 0.5f); _font.Draw(_spriteBatch, text, tx - rectangle.Width / 2, ty - rectangle.Height / 2, color); } } _blob.Draw(_spriteBatch); _spriteBatch.End(); }
public override void Show() { _tiledMap = AssetManager.Load <TiledMap>("tiled-map.json"); _tiledMap.Position = new Vector2(15, 40); _spriteBatch = new SpriteBatch(GraphicsDevice); var texture = AssetManager.Load <Texture>("blob.png"); _blob = new Sprite(texture) { Position = _tiledMap.GetTileAt(1, 0, 0).Centre }; RegisterInputProcessors(); _font = AssetManager.Load <BitmapFont>("courier-new-32.fnt"); base.Show(); }