-(NSArray*)nearbyBlocks:(SKNode*)blocks {
NSMutableArray *tmp = [NSMutableArray arrayWithCapacity:4];
NSArray *leftB = [blocks.name componentsSeparatedByString:@"_"];
/* LEFT */
SKNode *b = [background childNodeWithName:[NSString stringWithFormat:@"block_%i_%i", [[leftB objectAtIndex:1] intValue]-1, [[leftB objectAtIndex:2] intValue]]];
if ([blockArrayWalk containsObject:b]) {
[tmp addObject:b];
}
/* RIGHT */
b = [background childNodeWithName:[NSString stringWithFormat:@"block_%i_%i", [[leftB objectAtIndex:1] intValue]+1, [[leftB objectAtIndex:2] intValue]]];
if ([blockArrayWalk containsObject:b]) {
[tmp addObject:b];
}
/* UP */
b = [background childNodeWithName:[NSString stringWithFormat:@"block_%i_%i", [[leftB objectAtIndex:1] intValue], [[leftB objectAtIndex:2] intValue]+1]];
if ([blockArrayWalk containsObject:b]) {
[tmp addObject:b];
}
/* DOWN */
b = [background childNodeWithName:[NSString stringWithFormat:@"block_%i_%i", [[leftB objectAtIndex:1] intValue], [[leftB objectAtIndex:2] intValue]-1]];
if ([blockArrayWalk containsObject:b]) {
[tmp addObject:b];
}
return [NSArray arrayWithArray:tmp];
}
我已經運行時間探查現在當角色正在尋找一個路徑它尖峯。對於childNodeWithName的搜索是24%的黃色...每當路徑找到下一個塊時都會調用nearbyBlocks,所以它根據路徑長度調用多次。
的問題是,我需要使用SKNodes因爲炭可以掉下來,如果有人是下面取出塊...可能很快放棄比賽的想法;)檔案
與儀器,看看那裏的時間是正在度過。這裏沒有任何信息可以幫助任何人診斷您的問題。 – rickster 2014-10-28 22:03:49
我是一個xcode的新手:)謝謝你的提示,下班後我會這樣做,發佈更多信息:) – 2014-10-29 10:21:40