class SelectScene : cocos2d::CCLayer
{
public:
float g_width,g_height;
virtual bool init();
static cocos2d::CCScene* scene();
LAYER_NODE_FUNC(SelectScene);
void ccTouchesBegan(cocos2d::CCSet* pTouches, cocos2d::CCEvent* pEvent);
void onExit();
int counter;
};
then call setIsTouchEnabled in init()
bool SelectScene::init()
{
do
{
CCLayer::init();
......
this->setIsTouchEnabled(true);
CCLog("SelectScene completed");
return true;
} while (0);
return false;
}
Then it cause an error in CCTouchHandler.cpp at dynamic_cast(pDelegate)->retain(),before I actually see the SelectScene(a layer).
bool CCTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, int nPriority)
{
CCAssert(pDelegate != NULL, "touch delegate should not be null");
m_pDelegate = pDelegate;
dynamic_cast(pDelegate)->retain();
m_nPriority = nPriority;
m_nEnabledSelectors = 0;
return true;
}
dynamic_cast(pDelegate) returns NULL,leading to crash down.
Please help me with this problem.It really make us crazy.