Reprinted. For more information, see softboy.
Blog: http://www.softboy.uqc.cn
This tutorial is a larger cocos2d-2.0-rc2-x-2.0.1 than the previous changes, the previous version of the tutorial is really only for reference. the mouse event cocos2dx has been processed. here we only need to implement the corresponding virtual function.
// default implements are used to call script callback if exist virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent); virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent); virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent); virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent);
CcTouchesCancelled is a drag-and-drop effect. It can be viewed as a callback to be processed by the touch on the button and sliding to other buttons.
After the above function is implemented in HelloWorld, the following code must be installed in the initialization area. Otherwise, touch will not take effect.
setTouchEnabled(true);
Prompt if the definition is not found in CCSet. USING_NS_CC; defined outside helloword. h
The coordinate system is x up to right. y.
Previous: [cocos2d-x 2.0 + Game Development] animation creation
Next article: android 4.0 launcher 2 source code eclipse can be compiled (including android 4.1 launcher2 source code compilation)