当我尝试显示带有动画的 CCLabelBMFont 时,我的 Cocos2d 应用程序对某些用户随机失败。我无法在我的任何测试设备上重现该问题。因为它似乎在第 845 行失败了,所以我想知道我的内存是否用完了。我正在使用 cocos2d v2.0.0。
for (TileBlockModel* tile in [matchInfo tiles]) {
if (tile.matchScore > 0 && tile.spriteObject != nil) {
NSString* str = [NSString stringWithFormat:@"%d",tile.matchScore];
CCLabelBMFont* label = [CCLabelBMFont labelWithString:str fntFile:@"8-WHITE NUMBERS.fnt"];
label.position = ((CCNode*)tile.spriteObject).position;
label.scale = label.scale * fontMultiplier;
label.zOrder = TILE_BLOCK_SCORE_Z_LEVEL;
[gameGrid addChild:label];
CCActionInterval* action = [CCSequence actions:
[CCMoveBy actionWithDuration:.4 position:ccp(0, ((CCNode*)tile.spriteObject).boundingBox.size.height)],
[CCCallBlockN actionWithBlock:^(CCNode* node){
[node removeFromParentAndCleanup:YES];
}],
nil];
[label runAction:[CCSpeedPointer actionWithAction:action speed_:globalGameSpeed]];
}
}
崩溃日志
0 vault2richesiphone 0x00078a02 -[CCLabelBMFont setString:updateLabel:] (CCLabelBMFont.m:845)
1 vault2richesiphone 0x00078d29 -[CCLabelBMFont setFntFile:] (CCLabelBMFont.m:921)
2 vault2richesiphone 0x00077f1d -[CCLabelBMFont updateLabel] (CCLabelBMFont.m:622)
3 vault2richesiphone 0x000b58b3 -[gameViewController displayMatchScore:] (gameViewController.m:1100)
4 vault2richesiphone 0x000b68ab -[gameViewController animateColumnDrop:andRow:andOffset:animationId:] (gameViewController.m:1226)
5 vault2richesiphone 0x0006755d -[CCRepeat stop] (CCActionInterval.m:307)
6 vault2richesiphone 0x0006c4bf -[CCProgressTo startWithTarget:] (CCActionProgressTimer.m:53)
7 vault2richesiphone 0x0008ca59 +[CCShaderCache sharedShaderCache] (CCShaderCache.m:41)
8 vault2richesiphone 0x000a070d -[CCDirectorIOS setProjection:] (CCDirectorIOS.m:217)
9 QuartzCore 0x3581c7a9 _ZN2CA7Display11DisplayLink8dispatchEyy + 161
10 QuartzCore 0x3581c701 _ZN2CA7Display16IOMFBDisplayLink8callbackEP21__IOMobileFramebufferyyyPv + 65
11 IOMobileFramebuffer 0x37a98fd7 IOMobileFramebufferVsyncNotifyFunc + 155
12 IOKit 0x3480f5ad IODispatchCalloutFromCFMessage + 193
13 CoreFoundation 0x33bf188b __CFMachPortPerform + 119
14 CoreFoundation 0x33bfc3e7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 35
15 CoreFoundation 0x33bfc38b __CFRunLoopDoSource1 + 139
16 CoreFoundation 0x33bfb20f __CFRunLoopRun + 1383
17 CoreFoundation 0x33b6e23d CFRunLoopRunSpecific + 357
18 CoreFoundation 0x33b6e0c9 CFRunLoopRunInMode + 105
19 GraphicsServices 0x3774d33b GSEventRunModal + 75
20 UIKit 0x35a8a2b9 UIApplicationMain + 1121