Created
December 10, 2011 13:33
-
-
Save pratikshabhisikar/1455175 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)movePlayerPiecefrom:(NSUInteger)currentSquare withScore:(NSInteger)diceScore{ | |
| NSUInteger nextSquare = currentSquare + diceScore; | |
| if (nextSquare >= 100) { | |
| nextSquare = 100; | |
| // Check player 1 or player 2 and set the player to win. | |
| if (player == 1) { | |
| // Set player 1 won. | |
| }else { | |
| // Set player 2 won. | |
| } | |
| } | |
| boardView = (UIImageView *)[self.view viewWithTag: nextSquare]; | |
| // Animate player to next square. | |
| [UIView animateWithDuration:1.0f | |
| animations:^{ | |
| // Check player 1 or player 2 and animate the player. | |
| if (player == 1) { | |
| playerOneImage.center = boardView.center; | |
| }else { | |
| playerTwoImage.center = boardView.center; | |
| } | |
| // Here you can disable the game play so that while animation is in progress, player cannot do other operations like rotating the dice, etc... | |
| } | |
| completion:^(BOOL finished){ | |
| if(finished) { | |
| NSLog(@"Player moved to square:"); | |
| if (player == 1) { | |
| // Set player 1 position to next square. | |
| }else { | |
| // Set player two position to next square. | |
| } | |
| // Here check for snake and ladder match. And if matches, again call this function.. | |
| // Here you can enable the game play that disabled when animation started... | |
| } | |
| }]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment