public DebugOverlay(GameObjectManager game, GameObjectScreen screen, GameWindow window) { this.game = game; this.window = window; var box = new Box(new(0, 0, 500, 200), new(255, 255, 255, 100)); box.Layout = Layout.AnchorTop; updateText = new(new(0, 0, 10, 10), game.Fonts.Get("Assets/IBMPLEXSANS-MEDIUM.TTF", 15), "updates per second", Color.Gray) { Layout = Layout.Fill, TextWrapping = TextWrapMode.WordWrap, HorizontalTextAlignment = HorizontalTextAlignment.Center, VerticalTextAlignment = VerticalTextAlignment.Top }; screen.AddChild(box); game.AddObject(updateText); box.AddChild(updateText); }
public WaterGame() { _graphics = new GraphicsDeviceManager(this); _graphics.PreferredBackBufferWidth = 1600; _graphics.PreferredBackBufferHeight = 900; _graphics.SynchronizeWithVerticalRetrace = false; Window.AllowUserResizing = true; IsFixedTimeStep = false; //TargetElapsedTime = TimeSpan.FromMilliseconds(8.33); _graphics.ApplyChanges(); Screen = new(); Screen.RelativePosition = GraphicsDevice.Viewport.Bounds; Window.ClientSizeChanged += Window_ClientSizeChanged; gameObjectManager = new(GraphicsDevice); Screen.ChangeScreen(new DefaultScreen()); gameObjectManager.AddObject(Screen); Screen.UpdateScreenSize(new(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height)); Content.RootDirectory = "Content"; IsMouseVisible = true; #if DEBUG Screen.AddScreen(new DebugOverlay(gameObjectManager, Screen, Window)); #endif }
// Simple wrapper to avoid extra coding when adding GameObjects public void AddGameObject(GameObject gameObject, string tag, bool load = false, bool linkWithGameObjectManager = true) { GameObjectManager.AddObject(gameObject, tag, load, linkWithGameObjectManager); }