2014-10-28 67 views
0

我不知道iPad和iPhone之間是否有一些明顯的區別? 我正在用Sprite Kit,SKD 8.1和目標iOS 7.1開發遊戲。Sprite Kit和Pathfinding,iPad和iPhone之間的區別?

遊戲在測試過程中使用A *尋路來移動地圖上的2個字符。 我遇到的問題是當角色尋找路徑時。

在我的iPad 4,16gb上,查找路徑時查找凍結。 在我的iPhone 6和iPhone 4上,它完美無瑕。

它在模擬器上的偉大工程(新iPad的Retina,iPhone 4和iPhone 6),並沒有凍結在遊戲中,只在我的iPad 4 ...

有什麼我已經錯過了?該遊戲開發用於iPhone和iPad。 非常感謝您的幫助..

+0

與儀器,看看那裏的時間是正在度過。這裏沒有任何信息可以幫助任何人診斷您的問題。 – rickster 2014-10-28 22:03:49

+0

我是一個xcode的新手:)謝謝你的提示,下班後我會這樣做,發佈更多信息:) – 2014-10-29 10:21:40

回答

0
-(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因爲炭可以掉下來,如果有人是下面取出塊...可能很快放棄比賽的想法;)檔案