Cocos2d and SpriteBatchNode: cannot identify which sprite frame is causing an Assertion to fail

前端 未结 2 1736
盖世英雄少女心
盖世英雄少女心 2021-01-24 02:54

I have already asked something similar but I can\'t figure out properly how to debug this. That\'s the question.

I added some Exceptions handler (catches all Objective-C

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-24 03:53

    ok , looks like you have been there before ... Comment the first NSAssert, uncomment the if block. Then put a break point on the newly uncommented NSAssert. Execution will pause BEFORE the exception, and you should be to inspect the iVars of each class instance in the call stack (at least i can with AppCode, hope xCode allows that). Maybe you will get enough of a hint to figure out which texture/animation/batchnode is giving you a hard time.

    Also ... fyi. Whenever i start a project with cocos2d (any version) , i apply some 'standard' fixes to it so that my life will be easier for debugging. A standard 'patch' is to add a name to CCNode, which i set to some meaningful value : always. Also i override the descpription method to return MY name. Assigning meaningful names has helped me many times, especially when walking down (or up) the node hierarchy to figure out a bug. I also nuke many of the NSAsserts and whenever possible (especially in ctors), return nil and log an error message. As per Stefen's suggestion, if a cocos2d ctor returns me a nil, i spew out an error log message. I can then break on that log statement and drill-down the issue.

提交回复
热议问题