Tutorial 5: how to detect collisions (crash on device)

Tutorial 5: how to detect collisions (crash on device)
0.0 0


I just downloaded the tutorial sample project and after compiling it for: Device - Debug - SDK 4.2
I got a crash when testing on an ipod touch.
Here is the log:

warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/info/dns.so (file not found).
Assertion failed: (selector != __null), function schedule, file /Users/adamjohnston/Desktop/downloads/cocos2d-cocos2d-x-samples-605ee59/Cocos2dxSimpleGame/Cocos2dxSimpleGame/libs/cocos2dx/platform/CCNode_mobile.cpp, line 925.
Program received signal:  “SIGABRT”.

The assert is here:

void CCNode::schedule(SEL_SCHEDULE selector, ccTime interval)
    CCAssert( selector != NULL, "Argument must be non-nil"); //<--- ASSERT
    CCAssert( interval >=0, "Argument must be positive");

    CCScheduler::sharedScheduler()->scheduleSelector(selector, this, interval, !m_bIsRunning);

and it’s raised by:

this->schedule( schedule_selector(HelloWorld::update) );

If we comment the last line, the game runs on the device (but without collisions).
This crash is not happening on the iphone simulator neither the windows simulator.
Can somebody reproduce this error?



hmmm, it seems the problem is the name of the function,
if I change the name of the function HelloWorld::update to HelloWorld::updateGame
the game doesn’t crash in the device. (It was receiving a null pointer)
I suspect issues with c++ multiple inheritance, but I need to check more.


I have reproduced this bug this morning.
Now it’s very clear that

    void HelloWorld::update(ccTime dt);  // HelloWorldScene.h, line53

conflict with

    void SelectorProtocol::update(ccTime dt); // selector_protocol.h, line38

If I modity the 2nd function to void SelectorProtocol::updateMe(ccTime dt); and modify it’s calling in void CCScheduler::tick(ccTime dt) to make compilation successful, then HelloWorld::update will work well on my itouch. Renaming SelectorProtocol::update may affect other classes, so we mustn’t do this.

The inherit relation is: HelloWorld : CCLayerColor : CCLayer : CCNode : SelectorProtocol. I still don’t know why it works correctly on simulator, while crashes on device, why…

I just commit the source http://github.com/cocos2d/cocos2d-x-samples/commit/98603e070b5ee8258d435e748ba4508eccbeaae2. The document work is left to RongHong, the author, ha :stuck_out_tongue: