cocos2d-x版本:2.1.3
编译环境:vs2010(xp)
1.首先要重写下列三个函数
virtual void ccTouchesBegan(CCSet *touches,CCEvent *pEvent);
virtual void ccTouchesMoved(CCSet *touches,CCEvent *pEvent);
virtual void ccTouchesEnded(CCSet *touches,CCEvent *pEvent);
virtual void ccTouchesCancelled(CCSet *touches,CCEvent *pEvent);
2.然后在init函数里添加
setTouchEnabled(true);
3.然后实现上述三个函数
void HelloWorld::ccTouchesBegan( CCSet *touches,CCEvent *pEvent )
{
CCLOG("Began");
}
void HelloWorld::ccTouchesMoved( CCSet *touches,CCEvent *pEvent )
{
CCLOG("Moved");
}
void HelloWorld::ccTouchesEnded( CCSet *touches,CCEvent *pEvent )
{
CCLOG("Ended");
}
void HelloWorld::ccTouchesCancelled(CCSet *touches,CCEvent *pEvent)
{
CCLOG("Cancelled");
}