cocos2dx 在button回调函数里removeFromParent崩溃

找到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();
}

你可能感兴趣的:(游戏历程)