cocos2d-x的触摸事件分为 单点触摸事件 及 多点触摸事件
单点触摸事件:
void A::onEnter()
{
CCLayer::onEnter();
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, false);
}
void A::onExit()
{
CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this);
CCLayer::onExit();
}
bool HomeworkSelfLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
return true;
}
void HomeworkSelfLayer::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent)
{
}
void HomeworkSelfLayer::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
}
多点触摸事件:
void CourseSelectLayer::onEnter()
{
CCLayer::onEnter();
setTouchEnabled(true);
}
void A::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
}
void A::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
}
void A::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
}