Pig.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
	void Update ()
    {
	    if(isSinking)
        {
            if (t < 1.0f)
            {
                t += Time.deltaTime * sinkScale;
            }
        }
        else if(!isSinking)
        {
            if (t > 0.0f)
            {
                t -= Time.deltaTime * raiseScale;
            }
        }

        transform.position = Vector2.Lerp(basePosition, new Vector2(basePosition.x, basePosition.y - 1.0f), t);
    }

Usage Example

コード例 #1
0
        // ++++ NEEDS MOVING TO PIG MIND +++++ //
        private void UpdatePlayer(GameTime gameTime)
        {
            // update player
            pigObject.Update(gameTime);

            //// Get Thumbstick Controls
            //pigObjectTest.Position = new Vector2(currentGamePadState.ThumbSticks.Left.X * pigObjectTest.Velocity, pigObjectTest.Position.Y);
            //pigObjectTest.Position = new Vector2(pigObjectTest.Position.X, currentGamePadState.ThumbSticks.Left.Y * pigObjectTest.Velocity);

            // Use the Keyboard / Dpad
            if (currentKeyboardState.IsKeyDown(Keys.A) ||
                currentGamePadState.DPad.Left == ButtonState.Pressed)
            {
                pigObject.MoveLeft();
            }
            if (currentKeyboardState.IsKeyDown(Keys.D) ||
                currentGamePadState.DPad.Right == ButtonState.Pressed)
            {
                pigObject.MoveRight();
            }
            if (currentKeyboardState.IsKeyDown(Keys.W) ||
                currentGamePadState.DPad.Up == ButtonState.Pressed)
            {
                int i = 0;
                i++;
            }
            if (currentKeyboardState.IsKeyDown(Keys.S) ||
                currentGamePadState.DPad.Down == ButtonState.Pressed)
            {
                // IMPLEMENT SHIELD ACTIVATION?
            }

            //// Make sure that the player does not go out of bounds
            //player.Position.X = MathHelper.Clamp(player.Position.X, 0, GraphicsDevice.Viewport.Width - player.Width);
            //player.Position.Y = MathHelper.Clamp(player.Position.Y, 0, GraphicsDevice.Viewport.Height - player.Height);
        }