Cocos2d-x结构学习(三)CCTouchDelegate、CCAccelerometerDelegate、CCKeypadDelegate

前端之家收集整理的这篇文章主要介绍了Cocos2d-x结构学习(三)CCTouchDelegate、CCAccelerometerDelegate、CCKeypadDelegate前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、CCTouchDelegate类分析:用来处理触摸事件的委派类

class CC_DLL CCTouchDelegate
{
public:

    CCTouchDelegate() {}

    virtual ~CCTouchDelegate()
    {
    }

    virtual bool ccTouchBegan(CCTouch *pTouch,CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); return false;};  //触摸开始事件

    virtual void ccTouchMoved(CCTouch *pTouch,CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}           //触摸移动
    virtual void ccTouchEnded(CCTouch *pTouch,CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}           //触摸结束
    virtual void ccTouchCancelled(CCTouch *pTouch,CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}        //触摸取消

     virtual void ccTouchesBegan(CCSet *pTouches,CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}        //复数触摸开始
     virtual void ccTouchesMoved(CCSet *pTouches,CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}        //复数触摸移动
     virtual void ccTouchesEnded(CCSet *pTouches,CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}        //复数触摸结束
     virtual void ccTouchesCancelled(CCSet *pTouches,CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}    //复数触摸取消

};

2、CCAccelerometerDelegate类:加速计相关的委派类,只有一个函数
class CC_DLL CCAccelerometerDelegate
{
public:
    virtual void didAccelerate(CCAcceleration* pAccelerationValue) {CC_UNUSED_PARAM(pAccelerationValue);}
};

3、CCKeypadDelegate类:按键委派类,处理按键
class CC_DLL CCKeypadDelegate
{
public:
    virtual void keyBackClicked() {}      //按键返回

    virtual void keyMenuClicked() {};    //菜单单击,wophone和安卓
};
原文链接:https://www.f2er.com/cocos2dx/343829.html

猜你在找的Cocos2d-x相关文章