private static void HandleInput(float trigger, ButtonState shoulder, TransformedSprite spriteF, GamePadState gamePadState) { const float rotateAndScaleSpeed = 0.04f; Vector2 gamePadMovement = gamePadState.ThumbSticks.Left * 3.0f; gamePadMovement.Y = -gamePadMovement.Y; // Hold the trigger to transform if (trigger > 0) { // Left stick moves spriteF.Position += gamePadMovement; // Right stick rotates and scales spriteF.Rotation += gamePadState.ThumbSticks.Right.X * rotateAndScaleSpeed; spriteF.Scale += gamePadState.ThumbSticks.Right.Y * rotateAndScaleSpeed; } // Hold the shoulder to move the pivot point else if (shoulder == ButtonState.Pressed) { // with the left thumbstick spriteF.Origin += gamePadMovement; } }
private void HandleInput(TransformedSprite sprite, KeyboardState keyboardState, MouseState mouseState) { const float rotateAndScaleSpeed = 0.02f; Vector2 mousePosition = new Vector2(mouseState.X, mouseState.Y); float rotationDelta = (mouseState.ScrollWheelValue - lastScrollWheelValue) * 0.005f; // Click and drag to move sprite // Hold left control when dragging to move sprite's origin if (keyboardState.IsKeyDown(Keys.LeftControl)) { sprite.Origin = sprite.Position - mousePosition; } else { sprite.Position = mousePosition; } // Hold the left mouse button and spin the mouse wheel to rotate // Do it while holding alt to scale if (keyboardState.IsKeyDown(Keys.LeftAlt)) { sprite.Scale += rotationDelta; } else { sprite.Rotation += rotationDelta; } // Also allow the left and right arrow keys to rotate if (keyboardState.IsKeyDown(Keys.Left)) { sprite.Rotation -= rotateAndScaleSpeed; } else if (keyboardState.IsKeyDown(Keys.Right)) { sprite.Rotation += rotateAndScaleSpeed; } // And the up and down arrow keys to scale if (keyboardState.IsKeyDown(Keys.Up)) { sprite.Scale += rotateAndScaleSpeed; } else if (keyboardState.IsKeyDown(Keys.Down)) { sprite.Scale -= rotateAndScaleSpeed; } }
public bool IntersectPixels(TransformedSprite b) { return(IntersectPixels(transform, texture.Width, texture.Height, colorData, b.transform, b.texture.Width, b.texture.Height, b.colorData)); }