/// <summary> /// Inicializace všech objektů nutných pro existenci scény. /// </summary> public virtual void Load() { if (DebugView == null) { DebugView = new DebugView(Demo.World3D.World2D); DebugView.RemoveFlags(DebugViewFlags.Shape); DebugView.RemoveFlags(DebugViewFlags.Joint); DebugView.DefaultShapeColor = Color.White; DebugView.SleepingShapeColor = Color.LightGray; DebugView.TextColor = Color.Black; DebugView.LoadContent(Demo.GraphicsDevice, Demo.Content); } }
public override void LoadContent() { base.LoadContent(); if (World == null) { World = new World(Vector2.Zero); World.JointRemoved += JointRemoved; } else { World.Clear(); } // enable multithreading World.ContactManager.VelocityConstraintsMultithreadThreshold = 256; World.ContactManager.PositionConstraintsMultithreadThreshold = 256; World.ContactManager.CollideMultithreadThreshold = 256; if (DebugView == null) { DebugView = new DebugView(World); DebugView.RemoveFlags(DebugViewFlags.Shape); DebugView.RemoveFlags(DebugViewFlags.Joint); DebugView.DefaultShapeColor = Color.White; DebugView.SleepingShapeColor = Color.LightGray; DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Content); } if (Camera == null) { Camera = new Camera2D(ScreenManager.GraphicsDevice); } else { Camera.ResetCamera(); } HiddenBody = World.CreateBody(Vector2.Zero); // Loading may take a while... so prevent the game from "catching up" once we finished loading ScreenManager.Game.ResetElapsedTime(); }
private void EnableOrDisableFlag(DebugViewFlags flag) { if ((DebugView.Flags & flag) == flag) { DebugView.RemoveFlags(flag); } else { DebugView.AppendFlags(flag); } }
/// <summary> /// Allows the screen to handle user input. Unlike Update, this method /// is only called when the screen is active, and not when some other /// screen has taken the focus. /// </summary> public virtual void HandleInput(InputState input) { //Keyboard Input if (!input.LastKeyboardState.IsKeyDown(Key.F1) && input.CurrentKeyboardState.IsKeyDown(Key.F1)) { DebugViewEnabled = !DebugViewEnabled; Settings.EnableDiagnostics = DebugViewEnabled; if (DebugViewEnabled == false) { TxtDebug.Text = ""; } } if (!input.LastKeyboardState.IsKeyDown(Key.Escape) && input.CurrentKeyboardState.IsKeyDown(Key.Escape)) { ScreenManager.GoToMainMenu(); } //Mouse Point p = Transform.Inverse.Transform(new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y)); Vector2 position = new Vector2((float)p.X, (float)p.Y); if (input.CurrentMouseState.IsLeftButtonDown == false && input.LastMouseState.IsLeftButtonDown) { MouseUp(); } else if (input.CurrentMouseState.IsLeftButtonDown && input.LastMouseState.IsLeftButtonDown == false) { MouseDown(position); } MouseMove(position); //DebugView if (DebugView != null) { if (DebugViewEnabled) { DebugView.AppendFlags(DebugViewFlags.DebugPanel); } else { DebugView.RemoveFlags(DebugViewFlags.DebugPanel); } } }
public override void UnloadContent() { DebugView.RemoveFlags(DebugViewFlags.Shape); base.UnloadContent(); }