Game Development Reference
In-Depth Information
(2.0*M_PI))
tankStatsForLocal.tankDirection -=
(2.0*M_PI);
[self updateLocalTank];
}
}
}
6. In touchesEnded we must not do what we did in the other two touch methods;
here we will only update the tankDestination and tankDirection with
the local data structure and then call the same updateLocalTank method to
update the final position and rotation.
-(void)touchesEnded:(NSSet *)touches
withEvent:(UIEvent *)event
{
if (self.gameState == kGameStatePlaying)
{
if([touches count] == [[event
touchesForView:self.view] count])
{
tankStatsForLocal.tankDestination =
tankStatsForLocal.tankPosition;
tankStatsForLocal.tankDirection =
tankStatsForLocal.tankRotation;
[self updateLocalTank];
}
}
}
7. In all the touch methods, the updateLocalTank method is called to update the
final position and rotation. After updating these attributes for the local tank a net-
work packet is sent to sync with the remote tank player.
- (void)updateLocalTank
{
if( (fabs(tankStatsForLocal.tankPosition.x -
Search WWH ::




Custom Search