예제 #1
0
        public PhysicsGameScreen()
        {
            EnableCameraControl = true;

            this.mWorld = null;
            mCamera = null;
            this.mDebugViewXNA = null;
        }
 protected PhysicsGameScreen()
 {
     TransitionOnTime = TimeSpan.FromSeconds(0.75);
     TransitionOffTime = TimeSpan.FromSeconds(0.75);
     HasCursor = true;
     EnableCameraControl = true;
     _userAgent = null;
     World = null;
     Camera = null;
     DebugView = null;
 }
        public override void LoadContent()
        {
            base.LoadContent();

            //We enable diagnostics to show get values for our performance counters.
            Settings.EnableDiagnostics = true;

            if (World == null)
            {
                World = new World(Vector2.Zero);
            }
            else
            {
                World.Clear();
            }

            if (DebugView == null)
            {
                DebugView = new DebugViewXNA(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();
            }

            // Loading may take a while... so prevent the game from "catching up" once we finished loading
            ScreenManager.Game.ResetElapsedTime();
        }
예제 #4
0
        public override void LoadContent()
        {
            base.LoadContent();

            Settings.EnableDiagnostics = true;

            if (this.mWorld == null)
            {
                this.mWorld = new World(new Vector2(0, 0));
                if (ScreenManager.Game.Services.GetService(typeof(World)) == null)
                    ScreenManager.Game.Services.AddService(typeof(World), this.mWorld);
            }
            else
            {
                this.mWorld.Clear();
            }

            if (this.mDebugViewXNA == null)
            {
                this.mDebugViewXNA = new DebugViewXNA(mWorld);
                this.mDebugViewXNA.LoadContent(ScreenManager.GraphicsDevice,
                    ScreenManager.Game.Content);

                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.AABB);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.CenterOfMass);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.ContactNormals);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.ContactPoints);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.Controllers);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.DebugPanel);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.Joint);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.Pair);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.PerformanceGraph);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.PolygonPoints);
                this.mDebugViewXNA.RemoveFlags(DebugViewFlags.Shape);
            }

            if (mCamera == null)
            {
                mCamera = new Camera2D(ScreenManager.GraphicsDevice);
                mCamera.MaxRotation = 1000f;
                mCamera.MinRotation = -1000f;
            }
            else
            {
                mCamera.ResetCamera();
            }

            ScreenManager.Game.ResetElapsedTime();
        }