/// <summary> /// Update keyboard and mouse states. Runs Room.Update() and GameObjects.Update() after this. /// </summary> /// <remarks> /// Order of running: /// - PreUpdate() /// - <see cref="GMKeyboard.Update(GameTime)">Keyboard.Update()</see> /// - <see cref="GMMouse.Update()">Mouse.Update()</see> /// - Update() /// - For each GameObject in <see cref="Room.Objects">Objects</see> /// --> GameObject.Update() /// - PostUpdate() /// </remarks> /// <param name="gameTime">Current GameTime object</param> public void Update(GameTime gameTime) { if (Initialized) { GameTime = gameTime; PreUpdate(); Keyboard.Update(gameTime); Mouse.Update(); Update(); int roomWidth = Graphics.PreferredBackBufferWidth; int roomHeight = Graphics.PreferredBackBufferHeight; foreach (GameObject obj in Objects.ToList()) { if (DeActivateOutsideWindow) { if (obj.Position.X < -obj.Sprite.Width | obj.Position.Y < -obj.Sprite.Height | obj.Position.X >= roomWidth | obj.Position.Y >= roomHeight) { obj.Activated = false; } else { obj.Activated = true; } } if (obj.Activated) { obj.Update(gameTime); } } PostUpdate(); } }