Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to traverse peg through all the squares in a Monopoly type Game in iOS
    primarykey
    data
    text
    <p>How to traverse the peg through all the squares in a Monopoly type board Game ?</p> <p>I have written a function for the movepegbutton which on click moves the peg to the destination position which it gets from the random generated number.</p> <p>This is what I have written so far for the Move peg Button.</p> <pre><code>(IBAction)movePegButton:(id)sender { self.pegDestinationPositionIndex = self.pegCurrentPositionIndex + self.randomNumber; if (self.pegDestinationPositionIndex &gt; [self.boardCordinatesArray count] - 1) { self.pegDestinationPositionIndex = self.pegDestinationPositionIndex - [self.boardCordinatesArray count]; } [self animatePeg]; self.pegCurrentPositionIndex = self.pegDestinationPositionIndex; } </code></pre> <p>This is what I have written to animate the peg.</p> <pre><code>(void)animatePeg { int destinationXCord = [[[self.boardCordinatesArray objectAtIndex:self.pegDestinationPositionIndex] objectForKey:@"x"]intValue]; int destinationYCord = [[[self.boardCordinatesArray objectAtIndex:self.pegDestinationPositionIndex] objectForKey:@"y"]intValue]; [UIView animateWithDuration:1.0 animations:^{ self.peg.center = CGPointMake(destinationXCord, destinationYCord); }]; } </code></pre> <p>So far the peg moves correctly to the destination square but it is not traversing through all the squares in its way, for e.g. if it is 8X8 square, for first run dice rolls 6, the peg moves correctly to 6th square, for second run dice rolls 5, the peg moves correctly to the destination square but it directly jumps over to that position diagonally, it doesn't traverse the squares which it has in its way.</p> <p>I am stuck here, how should i do it ??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload