找到UIWidget.cpp文件:然后做以下修改(最新版本貌似已经做出了修正):
void Widget::pushDownEvent()
{
this->retain();
if (_touchEventCallback) {
_touchEventCallback(this,TouchEventType::BEGAN);
}
if (_touchEventListener && _touchEventSelector)
{
(_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_BEGAN);
}
this->release();
}
void Widget::moveEvent()
{
this->retain();
if (_touchEventCallback) {
_touchEventCallback(this,TouchEventType::MOVED);
}
if (_touchEventListener && _touchEventSelector)
{
(_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_MOVED);
}
this->release();
}
void Widget::releaseUpEvent()
{
this->retain();
if (_touchEventCallback) {
_touchEventCallback(this,TouchEventType::ENDED);
}
if (_touchEventListener && _touchEventSelector)
{
(_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_ENDED);
}
this->release();
}
void Widget::cancelUpEvent()
{
this->retain();
if (_touchEventCallback)
{
_touchEventCallback(this,TouchEventType::CANCELED);
}
if (_touchEventListener && _touchEventSelector)
{
(_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_CANCELED);
}
this->release();
}
原文链接:https://www.f2er.com/cocos2dx/345869.html