public AnalogDirectionControl(IAnalogDirectionControl control) { this.control = control; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here escapeControl = new DigitalFilterControl(Air.CreateKeyboardControl(Keys.Escape)); // You can use the Keys.ToDigitalControl() extension method // to create controls ButtonDirectionControl movementControl = new ButtonDirectionControl( Keys.A.ToDigitalControl(), Keys.D.ToDigitalControl(), Keys.W.ToDigitalControl(), Keys.S.ToDigitalControl()); // Or you can use Air.CreateKeyboardControl(Keys key) playerControls = new PlayerControls( new DigitalDirectionControl(movementControl), Air.CreateKeyboardControl(Keys.W).Filter(), Air.CreateKeyboardControl(Keys.Space).Filter(), Air.CreateKeyboardControl(Keys.P).Filter()); // Old way to get mouse position // mousePosition = Air.CreateMouseControl(); // New way to get mouse position mousePosition = Air.Mouse.Position; // Set up the "mouse cursor" // a 10x10 pixel brown square // I was too lazy to create an image in MS Paint #region Mouse Cursor Color[] mouseColor = new Color[100]; for (int i = 0; i < mouseColor.Length; i++) { mouseColor[i] = Color.Brown; } mouse = new Texture2D(GraphicsDevice, 10, 10, false, SurfaceFormat.Color); mouse.SetData<Color>(mouseColor); #endregion base.Initialize(); }