我不能安靜的身材如何調試此。我有一個CCScene運行,當場景被替換時,我收到以下錯誤消息。Cocos2d:令人討厭的異常與批量精靈
場景中有一個sprite批處理節點,其中添加了CCSpriteSubclass。
這就是清理方法及以下,你會發現斷言失敗消息:(INT)sceneId方法:
//Prepare sprites sheets for the rest of the game art
[frameCache addSpriteFramesWithFile:[NSString stringWithFormat:@"art%i-hd.plist", sceneId]];
sharedSpriteMainBatchNode = [CCSpriteBatchNode batchNodeWithFile:[NSString stringWithFormat:@"art%i-hd.png", sceneId]];
-(void) cleanup
{
[[GameController sharedGameController].musicLayer removeMusicSourceForKey:backgroundMusicFileName];
[CCTextureCache purgeSharedTextureCache];
[CCSpriteFrameCache purgeSharedSpriteFrameCache];
[CCAnimationCache purgeSharedAnimationCache];
// [[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
[super cleanup];
}
批次節點如下的initWithId創建然後我添加所有CCSpriteSubclass對象。
這是斷言失敗消息:
** Assertion failure in -[CCSpriteSubclass setTexture:], /Users/xxx/Desktop/xxx/xxx/libs/cocos2d/CCSprite.m:934
2012-12-03 12:54:33.335 RockTale[869:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'CCSprite: Batched sprites should use the same texture as the batchnode'
*** First throw call stack:
(0x338d28bf 0x303c61e5 0x338d27b9 0x311193b3 0x9ad43 0x9a2fb 0x4bca3 0x44ddf 0x38b07 0x503f7 0x94c03 0xbbeed 0xbcfe7 0x34fb7423 0x34fb7379 0x31b4cf93 0x36e52891 0x3389bf43 0x338a6553 0x338a64f5 0x338a5343 0x338284dd 0x338283a5 0x37f9afcd 0x3128b743 0x2edf 0x2ea0)
terminate called throwing an exception(lldb)
編輯:添加一個斷點到的SetTexture方法和這裏是我 「不」 看:)
EDIT 2 :我想我可以設法像在Java中一樣檢索完整的堆棧跟蹤。我在另一個問題中詢問了這個問題,並且我被告知應該添加一個全局異常..我仍然需要弄清楚如何檢索堆棧跟蹤。
不能安靜地找出哪一個..因爲我清除場景init中的紋理數據,因此我想應該沒有引用留在內存中。我添加了一個屏幕截圖,我在該方法中添加了一個斷點..您將能夠看到NSObject類類是「未知」..這是否意味着什麼?或只是由於cocos2d鑄造? – mm24
無法理解緩存清理如何對其產生影響。無論如何,只需檢查您添加到批處理節點的哪些精靈不在artNum.png圖集中。您也可以添加一個objective-c異常斷點,以便您看到導致此異常的實際行。 – Morion