
Untitled
By: a guest on
Jun 16th, 2012 | syntax:
C# | size: 0.79 KB | hits: 25 | expires: Never
public virtual void Update()
{
mouseState = Mouse.GetState();
if (mouseState.LeftButton == ButtonState.Pressed)
{
if (dragging)
position = new Vector2(mouseState.X, mouseState.Y); // il pezzo si muove seguendo il mouse
else if (IsMouseIn)
dragging = true;
}
else if (dragging)
{
dragging = false;
int squareCenter = (int)board.SquareSize / 2;
Point casella = new Point((int)(position.X / board.SquareSize), (int)(position.Y / board.SquareSize));
position = new Vector2(casella.X * board.SquareSize + squareCenter, casella.Y * board.SquareSize + squareCenter);
}