In. declare in h: [cpp] TouchDispatcher (void); virtual bool ccTouchBegan (CCTouch * pTouch, CCEvent * pEvent); virtual void ccTouchMoved (CCTouch * pTouch, CCEvent * pEvent ); virtual void ccTouchEnded (CCTouch * pTouch, CCEvent * pEvent); virtual void ccTouchCancelled (CCTouch * pTouch, CCEvent * pEvent); and in. set in init () of cpp: [cpp] this-> setTouchEnabled (true); The following is the implementation of the Touch function: [cpp] void DragScene: registerWithTouchDispatcher (Void) {CCDirector: sharedDirector ()-> getTouchDispatcher ()-> addTargetedDelegate (this, 0, true);} bool DragScene: ccTouchBegan (CCTouch * pTouch, CCEvent * pEvent) {mBullet-> setPosition (ccp (pTouch-> getLocation (). x, pTouch-> getLocation (). y); return true;} void DragScene: ccTouchMoved (CCTouch * pTouch, CCEvent * pEvent) {mBullet-> setPosition (ccp (pTouch-> getLocation (). x, pTouch-> getLocation (). y ));} Void DragScene: ccTouchEnded (CCTouch * pTouch, CCEvent * pEvent) {} void DragScene: ccTouchCancelled (CCTouch * pTouch, CCEvent * pEvent) {} let the genie follow the touch when touching, that is, update the genie position in ccTouchMoved.: