Esempio n. 1
0
    public CustomCommandSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      // Add a DelegateGraphicsScreen as the first graphics screen to the graphics
      // service. This lets us do the rendering in the Render method of this class.
      var graphicsScreen = new DelegateGraphicsScreen(GraphicsService)
      {
        RenderCallback = Render
      };
      GraphicsService.Screens.Insert(0, graphicsScreen);

      _spriteBatch = GraphicsService.GetSpriteBatch();

      // Load a few SpriteFonts for rendering.
      _textFont = UIContentManager.Load<SpriteFont>("UI Themes/WindowsPhone7/Segoe15");
      _buttonFont = ContentManager.Load<SpriteFont>("ButtonImages/xboxControllerSpriteFont");

      // Add custom commands to input service.
      _buttonHoldCommand = new ButtonHoldCommand(Buttons.A, 1.0f) { Name = "Hold A" };
      _buttonTapCommand = new ButtonTapCommand(Buttons.A, 0.2f, 1.0f) { Name = "Tap A" };
      _buttonSequenceCommand = new ButtonSequenceCommand(new [] { Buttons.A, Buttons.B, Buttons.A, Buttons.B }, 2.0f) { Name = "A-B-A-B" };
      InputService.Commands.Add(_buttonHoldCommand);
      InputService.Commands.Add(_buttonTapCommand);
      InputService.Commands.Add(_buttonSequenceCommand);
    }
        public CustomCommandSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Add a DelegateGraphicsScreen as the first graphics screen to the graphics
            // service. This lets us do the rendering in the Render method of this class.
            var graphicsScreen = new DelegateGraphicsScreen(GraphicsService)
            {
                RenderCallback = Render
            };

            GraphicsService.Screens.Insert(0, graphicsScreen);

            _spriteBatch = GraphicsService.GetSpriteBatch();

            // Load a few SpriteFonts for rendering.
            _textFont   = UIContentManager.Load <SpriteFont>("UI Themes/WindowsPhone7/Segoe15");
            _buttonFont = ContentManager.Load <SpriteFont>("ButtonImages/xboxControllerSpriteFont");

            // Add custom commands to input service.
            _buttonHoldCommand = new ButtonHoldCommand(Buttons.A, 1.0f)
            {
                Name = "Hold A"
            };
            _buttonTapCommand = new ButtonTapCommand(Buttons.A, 0.2f, 1.0f)
            {
                Name = "Tap A"
            };
            _buttonSequenceCommand = new ButtonSequenceCommand(new [] { Buttons.A, Buttons.B, Buttons.A, Buttons.B }, 2.0f)
            {
                Name = "A-B-A-B"
            };
            InputService.Commands.Add(_buttonHoldCommand);
            InputService.Commands.Add(_buttonTapCommand);
            InputService.Commands.Add(_buttonSequenceCommand);
        }