Why sometimes ccTouchEnded couldn't be called?


#1

I’ve defined a class which extends CCControlButton, and I just overwrite the function ccTouchBegan and ccTouchEnded to satisfy my Requirements. But when I use my own class, the function ccTouchEnded will not be called sometimes. Excuse me, who knows the reason of this case? (My sourse code is below)

bool SCControlButton::ccTouchBegan(CCTouch pTouch, CCEventpEvent)
{
if (!isTouchInside(pTouch) || !isEnabled())
{
return false;
}
//this part is that I’ve overwriten.
if
m_eState = CCControlStateNormal;
else
m_eState=CCControlStateHighlighted;

m_isPushed=true;
this->setHighlighted(true);
sendActionsForControlEvents(CCControlEventTouchDown);

isMoved = false;

return true;
}

void SCControlButton::ccTouchEnded(cocos2d::CCTouch pTouch, cocos2d::CCEventpEvent)
{
m_isPushed = false;
setHighlighted(false);

//this part is that I’ve overwriten.
*if
return;
*
if (isTouchInside(pTouch))
{
sendActionsForControlEvents(CCControlEventTouchUpInside);
}
else
{
sendActionsForControlEvents(CCControlEventTouchUpOutside);
}
}