Game Development Reference
In-Depth Information
Listing 4-27. CoinsController.m (checkMatches)
-(void)checkMatches{
matchingRows = [coinsGame findMatchingRows];
matchingCols = [coinsGame findMatchingCols];
int rowCount = [coinsGame rowCount];
int colCount = [coinsGame colCount];
BOOL isDelegateSet = NO;
if ([matchingRows count] > 0){
for (NSNumber* row in matchingRows){
for (int c = 0;c<colCount;c++){
CABasicAnimation* animateOffScreen = [CABasicAnimation
animationWithKeyPath:@"position.x"];
[animateOffScreen setValue:@"animateOffScreen" forKey:@"name"];
animateOffScreen.byValue = [NSNumber numberWithFloat:coinsView.frame.size.width];
animateOffScreen.duration = 2.0;
animateOffScreen.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseIn];
Coord coord = CoordMake([row intValue], c);
int index = [coinsGame indexForCoord:coord];
UIImageView* coinView = [[coinsView subviews] objectAtIndex: index];
if (c == 0){
[animateOffScreen setDelegate:self];
isDelegateSet = YES;
}
[coinView.layer addAnimation:animateOffScreen forKey:@"animateOffScreenX"];
}
}
}
if ([matchingCols count] > 0){
for (NSNumber* col in matchingCols){
for (int r = 0;r<rowCount;r++){
CABasicAnimation* animateOffScreen = [CABasicAnimation
animationWithKeyPath:@"position.y"];
[animateOffScreen setValue:@"animateOffScreen" forKey:@"name"];
animateOffScreen.byValue = [NSNumber numberWithFloat:coinsView.frame.size.height];
animateOffScreen.duration = 2.0;
animateOffScreen.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseIn];
Search WWH ::




Custom Search