/// <summary> /// Constructor. /// </summary> public LevelScreen() { TransitionOnTime = TimeSpan.FromSeconds(1.5); TransitionOffTime = TimeSpan.FromSeconds(0.5); pauseAction = new InputAction( new Buttons[] { Buttons.Start, Buttons.Back }, new Keys[] { Keys.Escape }, true); debugAction = new InputAction( new Buttons[0], new Keys[] { Keys.F1 }, true); zoomInAction = new InputAction( null, new Keys[] {Keys.Q}, false); zoomOutAction = new InputAction( null, new Keys[] { Keys.E }, false); #region player controls: moveDownAction = new InputAction( null, new Keys[] { Keys.S, Keys.Down }, false); moveUpAction = new InputAction( new Buttons[] {Buttons.A, Buttons.DPadUp }, new Keys[] { Keys.W, Keys.Up, Keys.Space }, false); moveRightAction = new InputAction( new Buttons[] { Buttons.DPadRight, Buttons.LeftThumbstickRight }, new Keys[] { Keys.D, Keys.Right }, false); moveLeftAction = new InputAction( new Buttons[] { Buttons.DPadLeft, Buttons.LeftThumbstickLeft }, new Keys[] { Keys.A, Keys.Left }, false); #endregion world = null; player = null; scenario = null; debug = false; playerControl = true; }
/// <summary> /// Load graphics content for the game. /// </summary> public override void Activate(bool instancePreserved) { if (!instancePreserved) { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Content"); #region Instantiating Fields: gameFont = ScreenManager.Font; world = new GameWorld(9.8f * Vector2.UnitY, 0.4f, new Camera2D(ScreenManager.GraphicsDevice)); player = new Player(this, world, camera); player.Initialize(); player.Position = new Vector2(0, 50); scenario = new Scenario(this, world, camera); scenario.Initialize(); camera.Zoom = 7f; camera.trakingSpeedMult = new Vector2(0.5f, 0.25f); camera.trakingOffset = new Vector2(0f, -2f); camera.TrackingBody = player.getBody(0); camera.Update(new GameTime()); camera.Jump2Target(); debugView = new DebugViewXNA(world); debugView.AppendFlags(DebugViewFlags.DebugPanel | DebugViewFlags.PerformanceGraph); debugView.AppendFlags(DebugViewFlags.ContactNormals | DebugViewFlags.ContactPoints); debugView.DefaultShapeColor = Color.Black; debugView.SleepingShapeColor = Color.LightGray; collectibles = new List<Collectible>(); myEffect = new ParticleEffect(); myRenderer = new SpriteBatchRenderer { GraphicsDeviceService = (IGraphicsDeviceService)ScreenManager.Game.Services.GetService(typeof(IGraphicsDeviceService)) }; sbRenderer = new SpriteBatchRenderer { GraphicsDeviceService = (IGraphicsDeviceService)ScreenManager.Game.Services.GetService(typeof(IGraphicsDeviceService)) }; #endregion loadContent(content); ScreenManager.Game.ResetElapsedTime(); } }