加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2d-x 3.0 点击button,点击事件响应两次

发布时间:2020-12-14 19:51:40 所属栏目:百科 来源:网络整理
导读:内容转自:http://www.cocoachina.com/bbs/read.php?tid=184686 原因:3.0 版本的点击按钮事件被集合在一起了,点击抬起移动都会触发,需要自己来判断触发类型。 示例: void UIButtonTest::touchEvent(CCObject *pSender,TouchEventType type) { switch (ty

内容转自:http://www.cocoachina.com/bbs/read.php?tid=184686


原因:3.0版本的点击按钮事件被集合在一起了,点击抬起移动都会触发,需要自己来判断触发类型。

示例:

void UIButtonTest::touchEvent(CCObject *pSender,TouchEventType type) 
{ 
    switch (type) 
    { 
        case TOUCH_EVENT_BEGAN://触摸开始 
            m_pDisplayValueLabel->setText(CCString::createWithFormat("Touch Down")->getCString()); 
            break; 
             
        case TOUCH_EVENT_MOVED://触摸移动 
            m_pDisplayValueLabel->setText(CCString::createWithFormat("Touch Move")->getCString()); 
            break; 
             
        case TOUCH_EVENT_ENDED://触摸结束(在控件内抬起) 
            m_pDisplayValueLabel->setText(CCString::createWithFormat("Touch Up")->getCString()); 
            break; 
             
        case TOUCH_EVENT_CANCELED://触摸取消(在控件外抬起) 
            m_pDisplayValueLabel->setText(CCString::createWithFormat("Touch Cancelled")->getCString()); 
            break; 
             
        default: 
            break; 
    } 
} 

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读