Creating a delay for my board piece?
Hi,
I am creating a board game and I want the board piece to jump to the next "box"/"slot" with a delay. For example I roll a 6 then I want the character to go to slot 1, slot 2, slot 3 etc. until slot 6 with a small delay as it was a real game.
However I can't get it to work. Right now I have this code in Draw:
[code] protected override void Draw(GameTime gameTime) {
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
spriteBatch.Begin();
spriteBatch.Draw(background, new Rectangle(0,0, 800, 800), Color.White);
spriteBatch.End();
/* for (int x = 0; x < 40; x++)
{
spriteBatch.Begin();
spriteBatch.Draw(background, gameBoard.board[x], Color.Red);
spriteBatch.End();
}
*/
spriteBatch.Begin();
spriteBatch.Draw(benderPiece, new Rectangle((int)benderPos.X, (int)benderPos.Y, 50, 50), Color.White);
spriteBatch.End();
spriteBatch.Begin();
spriteBatch.DrawString(spriteFont, dice.ToString(), new Vector2(125, 125), Color.Black);
spriteBatch.End();
spriteBatch.Begin();
if (playerMoved == false && dice != 0)
{
for (int i = 0; i <= dice; i++)
{
benderPos.X = gameBoard.board[benderSquarePos].X;
benderPos.Y = gameBoard.board[benderSquarePos].Y;
benderSquarePos += 1;
spriteBatch.Draw(benderPiece, new Rectangle((int)benderPos.X, (int)benderPos.Y, 50, 50), Color.White);
Thread.Sleep(1250);
}
dice = 0;
}
spriteBatch.End();
base.Draw(gameTime);
}
}[/code]
However what happens is that it delays and then it the number of the dice but very fast.
How can I make so that the delay is between every movement?
I have tried to have it in the Update as well but I can't get it to work.
Best regards,
Tomas