内容转自: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; } }原文链接:/cocos2dx/345373.html