KeyboardControls.Update C# (CSharp) Méthode

Update() private méthode

private Update ( ) : void
Résultat void
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
            theCharacterJump.Jump();

        if (Input.GetKeyDown(KeyCode.D))
        {
            theCharacterMotor.RightActivation();
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            theCharacterMotor.LeftActivation();
        }
        if (Input.GetKeyUp(KeyCode.D))
        {
            theCharacterMotor.movingRight=false;
        }

        if (Input.GetKeyUp(KeyCode.A))
        {
            theCharacterMotor.movingLeft=false;
        }

        if(Input.GetKeyDown(KeyCode.F))
        {
            theCharacterDrill.shot();
        }
    }

Usage Example

Exemple #1
0
 /// <summary>
 /// Allows the game to run logic such as updating the world,
 /// checking for collisions, gathering input, and playing audio.
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 ///
 protected override void Update(GameTime gameTime)
 {
     keyboard.Update();
     gamepad.Update();
     if (State.Type != SuperMario.Interfaces.GameStates.Pause)
     {
         objectManager.Update();
     }
     MarioInfo.timeCount(gameTime, Mario);
     camera2.LookAt(new Vector2(Mario.Location.X - 20, GraphicsDevice.Viewport.Height / 2));
     base.Update(gameTime);
 }