当前位置: 首页>>代码示例>>C#>>正文


C# InputHelper类代码示例

本文整理汇总了C#中InputHelper的典型用法代码示例。如果您正苦于以下问题:C# InputHelper类的具体用法?C# InputHelper怎么用?C# InputHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InputHelper类属于命名空间,在下文中一共展示了InputHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GameWorld

    public GameWorld(int width, int height, ContentManager Content)
    {
        screenWidth = width;
        screenHeight = height;
        random = new Random();
        gameState = GameState.Menu;
        inputHelper = new InputHelper();
        block = Content.Load<Texture2D>("block");
        reset = Content.Load<Texture2D>("reset");
        font = Content.Load<SpriteFont>("SpelFont");
        font2 = Content.Load<SpriteFont>("SpriteFont1");
        font3 = Content.Load<SpriteFont>("SpriteFont2");
        playButton = Content.Load<Texture2D>("Play");
        optionsButton = Content.Load<Texture2D>("Options");
        backButton = Content.Load<Texture2D>("Back");
        polytris = Content.Load<Texture2D>("Polytris");
        grid = new TetrisGrid(block);
        level = 1;
        levelspeed = 1;
        score = 0;
        i = (int)random.Next(7) + 1;
        i2 = (int)random.Next(7) + 1;
        blockcounter = 1;

        blocks = new BlockList(block, Content);          //Voegen de verschillende blockobjecten toe aan de lijst
        block1 = new Block1(block, Content);
        blocks.Add(block1, 1);
        block2 = new Block2(block, Content);
        blocks.Add(block2, 2);
        block3 = new Block3(block, Content);
        blocks.Add(block3, 3);
        block4 = new Block4(block, Content);
        blocks.Add(block4, 4);
        block5 = new Block5(block, Content);
        blocks.Add(block5, 5);
        block6 = new Block6(block, Content);
        blocks.Add(block6, 6);
        block7 = new Block7(block, Content);
        blocks.Add(block7, 7);

        //Voegen de verschillende blockobjecten toe aan een tweede lijst voor het tekenen van het volgende blokje
        block1res = new Block1(block, Content);
        blocks.AddToReserve(block1res, 1);
        block2res = new Block2(block, Content);
        blocks.AddToReserve(block2res, 2);
        block3res = new Block3(block, Content);
        blocks.AddToReserve(block3res, 3);
        block4res = new Block4(block, Content);
        blocks.AddToReserve(block4res, 4);
        block5res = new Block5(block, Content);
        blocks.AddToReserve(block5res, 5);
        block6res = new Block6(block, Content);
        blocks.AddToReserve(block6res, 6);
        block7res = new Block7(block, Content);
        blocks.AddToReserve(block7res, 7);

        options = new Options(block, reset, backButton, width, height, font, blocks);
        menu = new Menu(playButton, optionsButton, polytris, width, height);
        gameOver = new GameOver(backButton, width, height);
    }
开发者ID:Supercarlijn,项目名称:Tetris,代码行数:60,代码来源:GameWorld.cs

示例2: HandleInput

    /// <summary>
    /// HandleInput for the button
    /// </summary>
    /// <param name="inputHelper">The inputhelper to react to input</param>
    public override void HandleInput(InputHelper inputHelper)
    {
        wasMouseOver = isMouseOver;
        //Checking whether the mouse is hovering over a button or not
        if (BoundingBox.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y))
            isMouseOver = true;
        else
            isMouseOver = false;

        if (!wasMouseOver && isMouseOver)
        {
            foreach (Sound sound in MusicPlayer.SoundEffect)
                if (sound.Name == "MouseOver")
                {
                    sound.PlaySound();
                }
        }

        buttonWasPressed = ButtonIsPressed;
        //Checking whether you are pressing the button or not
        if (inputHelper.MouseLeftButtonPressed() && isMouseOver)
            buttonIsPressed = true;
        else
            buttonIsPressed = false;

        if (!buttonWasPressed && buttonIsPressed)
        {
            foreach (Sound sound in MusicPlayer.SoundEffect)
                if (sound.Name == "MouseClick")
                {
                    sound.PlaySound();
                }
        }
    }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:38,代码来源:Button.cs

示例3: HandleInput

        public override void HandleInput(InputHelper inputHelper)
        {
            base.HandleInput(inputHelper);

            if (backButton.Pressed)
                GameEnvironment.GameStateManager.SwitchTo("titleMenu");
        }
开发者ID:golddevelopment,项目名称:TickTick,代码行数:7,代码来源:HelpState.cs

示例4: HandleInput

 public override void HandleInput(InputHelper inputHelper)
 {
     if (inputHelper.IsKeyDown(Keys.Escape))
         escDown = true;
     else
         escDown = false;
 }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:7,代码来源:CreditState.cs

示例5: HandleInput

 public override void HandleInput(InputHelper inputHelper)
 {
     if (!inputHelper.KeyPressed(Keys.Space))
         return;
     playingState.Reset();
     GameEnvironment.GameStateManager.SwitchTo("playingState");
 }
开发者ID:MiloBuwalda,项目名称:ticktack,代码行数:7,代码来源:GameOverState.cs

示例6: HandleInput

 /// <summary>Enables going to the next level.</summary>
 public override void HandleInput(InputHelper inputHelper)
 {
     if (!(inputHelper.KeyPressed(Keys.Space) || inputHelper.ControlerButtonPressed(Buttons.A)))
         return;
     GameEnvironment.GameStateManager.SwitchTo("playingState");
     (playingState as PlayingState).NextLevel();
 }
开发者ID:alikimoko,项目名称:Practicum3.Platformer,代码行数:8,代码来源:LevelFinishedState.cs

示例7: GameObject

 public GameObject(string id = "")
 {
     this.velocity = Vector2.Zero;
     this.visible = true;
     inputHelper = new InputHelper();
     this.id = id;
 }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:7,代码来源:GameObject.cs

示例8: HandleInput

        public override void HandleInput(InputHelper inputHelper)
        {
            base.HandleInput(inputHelper);

            if (obj == null)
            {
                Vector3 vectorToAdd = Vector3.Zero;

                if (inputHelper.IsKeyDown(Keys.W))
                    vectorToAdd -= Vector3.UnitZ;
                if (inputHelper.IsKeyDown(Keys.S))
                    vectorToAdd += Vector3.UnitZ;
                if (inputHelper.IsKeyDown(Keys.D))
                    vectorToAdd += Vector3.UnitX;
                if (inputHelper.IsKeyDown(Keys.A))
                    vectorToAdd -= Vector3.UnitX;
                if (inputHelper.IsKeyDown(Keys.Q))
                    vectorToAdd -= Vector3.UnitY;
                if (inputHelper.IsKeyDown(Keys.E))
                    vectorToAdd += Vector3.UnitY;
                if (inputHelper.IsKeyDown(Keys.R))
                    position = Vector3.Zero;
                if (inputHelper.IsKeyDown(Keys.D1))
                    walkSpeed /= 1.25f;
                if (inputHelper.IsKeyDown(Keys.D2))
                    walkSpeed *= 1.25f;

                inputHelper.AddMouseRotation(rotSpeed, ref rotation);
                Matrix cameraRotation = Matrix.CreateRotationX(rotation.X) * Matrix.CreateRotationY(rotation.Y);
                Vector3 rotatedVector = Vector3.Transform(vectorToAdd * walkSpeed, cameraRotation);
                position += rotatedVector;
            }
        }
开发者ID:Dutchman97,项目名称:Game1,代码行数:33,代码来源:CameraObject.cs

示例9: BalloonFW

 public BalloonFW()
 {
     Content.RootDirectory = "Content";
     graphics = new GraphicsDeviceManager(this);
     inputHelper = new InputHelper();
     this.IsMouseVisible = true;
 }
开发者ID:pienpien34,项目名称:BalloonFW,代码行数:7,代码来源:Painter.cs

示例10: HandleInput

 /// <summary>
 /// Checks the difference between the old and new mouse position
 /// </summary>
 /// <param name="inputHelper">The inputhelper to react to input</param>
 public override void HandleInput(InputHelper inputHelper)
 {
     inputHelper.Update();
     mouseDiff.X = inputHelper.MousePosition.X - prevMousePos.X;
     mouseDiff.Y = inputHelper.MousePosition.Y - prevMousePos.Y;
     prevMousePos = new Vector2(GameEnvironment.Screen.X / 2, GameEnvironment.Screen.Y / 2);
     Mouse.SetPosition((int)prevMousePos.X, (int)prevMousePos.Y);
 }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:12,代码来源:Camera.cs

示例11: HandleInput

 public override void HandleInput(InputHelper inputHelper)
 {
     base.HandleInput(inputHelper);
     if (playButton.Pressed)
         GameEnvironment.GameStateManager.SwitchTo("levelMenu");
     else if (helpButton.Pressed)
         GameEnvironment.GameStateManager.SwitchTo("helpState");
 }
开发者ID:MiloBuwalda,项目名称:ticktack,代码行数:8,代码来源:TitleMenuState.cs

示例12: HandleInput

 /// <summary>
 /// Responds to user input, accepting or cancelling the message box.
 /// </summary>
 public override void HandleInput(InputHelper input, GameTime gameTime)
 {
     if (input.IsMenuSelect() || input.IsMenuCancel() ||
         input.IsNewMouseButtonPress(MouseButtons.LeftButton))
     {
         ExitScreen();
     }
 }
开发者ID:AndrewCarre,项目名称:WizardsNeverDie,代码行数:11,代码来源:MessageBoxScreen.cs

示例13: Initialize

        /// <summary>
        /// Initializes the component.
        /// </summary>
        public override void Initialize()
        {
#if WINDOWS_PHONE
            // Enable tap gesture
            TouchPanel.EnabledGestures = GestureType.Tap;
#endif
            // Get xbox cursor
            inputHelper = null;
            for (int componentIndex = 0; componentIndex < Game.Components.Count; componentIndex++)
            {
                if (Game.Components[componentIndex] is InputHelper)
                {
                    inputHelper = (InputHelper)Game.Components[componentIndex];
                    break;
                }
            }

            // Show mouse
            Game.IsMouseVisible = true;
            base.Initialize();

            spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            // Calculate chips position for the chip buttons which allow placing the bet
            Rectangle size = chipsAssets[assetNames[0]].Bounds;

            Rectangle bounds = Game.GraphicsDevice.Viewport.TitleSafeArea();

            positions[chipsAssets.Count - 1] = new Vector2(bounds.Left + 10,
                bounds.Bottom - size.Height - 80);
            for (int chipIndex = 2; chipIndex <= chipsAssets.Count; chipIndex++)
            {
                size = chipsAssets[assetNames[chipsAssets.Count - chipIndex]].Bounds;
                positions[chipsAssets.Count - chipIndex] = positions[chipsAssets.Count - (chipIndex - 1)] -
                    new Vector2(0, size.Height + 10);
            }

            // Initialize bet button
            bet = new Button("ButtonRegular", "ButtonPressed", input, cardGame)
            {
                Bounds = new Rectangle(bounds.Left + 10, bounds.Bottom - 60, 100, 50),
                Font = cardGame.Font,
                Text = "Deal",
            };
            bet.Click += Bet_Click;
            Game.Components.Add(bet);

            // Initialize clear button
            clear = new Button("ButtonRegular", "ButtonPressed", input, cardGame)
            {
                Bounds = new Rectangle(bounds.Left + 120, bounds.Bottom - 60, 100, 50),
                Font = cardGame.Font,
                Text = "Clear",
            };
            clear.Click += Clear_Click;
            Game.Components.Add(clear);
            ShowAndEnableButtons(false);
        }
开发者ID:liwq-net,项目名称:SilverSprite,代码行数:61,代码来源:BetGameComponent.cs

示例14: HandleInput

 public override void HandleInput(InputHelper inputHelper)
 {
     if (inputHelper.IsKeyPressed(Keys.P))
     {
         paused = !paused;
         pausedText.Visible = paused;
     }
     base.HandleInput(inputHelper);
 }
开发者ID:Chartle,项目名称:Gameprogrammeren-Practica,代码行数:9,代码来源:FourPlayerState.cs

示例15: GameEnvironment

 public GameEnvironment()
 {
     modelScale = Matrix.CreateScale(1, 1, 1);
     inputHelper = new InputHelper();
     gameStateManager = new GameStateManager();
     random = new Random();
     assetManager = new AssetManager(Content);
     gameSettingsManager = new GameSettingsManager();
 }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:9,代码来源:GameEnvironment.cs


注:本文中的InputHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。