cocos模拟touch,模拟滑动

该博客介绍了如何在Cocos2d-x中模拟触摸事件,包括touchBegin、touchMove和touchEnd,以实现滑动操作。通过处理不同平台的触摸坐标转换,确保在Android和非Android设备上的兼容性。
摘要由CSDN通过智能技术生成

                intptr_t ids[] = { 2029930560};

#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID

                float xxs[] = {(float)currentClickableObj.x * scrWidth /1136};

                float yys[] = {(640-(float)currentClickableObj.y) * scrHeight /640};

                CCEGLView* view = cocos2d::CCDirector::sharedDirector()->getOpenGLView();   

                view->handleTouchesBegin(1, ids, xxs, yes);        //注册touch按下开始

#else

                float xxs[] = {(float)currentClickableObj.x};

                float yys[] = {(640-(float)currentClickableObj.y)};

                GLViewProtocol* eglView =cocos2d::Director::getInstance()->getOpenGLView();

                eglView->handleTouchesBegin(1, ids, xxs, yys);

#endif

                //touch滑动

                moveToTager(Vec2(currentClickableObj.x,currentClickableObj.y),Vec2(currentClickableObj.x -800, currentClickableObj.y));

                

             //   CCLOG("HandManager::Village schedule");


                m_delayDelegates.push_back(DelayCallDelegate::getInstance(0.2,1, [&]()

                  {

                      intptr_t ids[] = { 2029930560};

                      float xxs[] = {(float)currentClickableObj.x - 800};

                      float yys[] = { 640-(float)currentClickableObj.y};

                      

#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID

                 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值