cocos2dx 3.15 擦除判断,iphonex和xr崩溃,求助,急急急。。。。

bool HelloWorld::myIsDataClear(RenderTexture *pRenderTexture)
{
bool m_bEraserOk = false;

Image* image = new Image();
image = pRenderTexture->newImage(true);

int m = 3;
if (image->hasAlpha())
{
    m = 4;
}

unsigned char *data_ = image->getData();

int x = 0, y = 0;
/// 这里要提醒一点,即Opengl下,其中心点坐标在左上角
for (x = 0; x < pRenderTexture->getContentSize().width; ++x)
{
    for (y = 0; y < pRenderTexture->getContentSize().height; ++y)
    {
        //获取每个点的像素点值
        unsigned char *pixel = data_ + (x + y * image->getWidth()) * m;

        // You can see/change pixels' RGBA value(0-255) here !
        unsigned int r = (unsigned int)*pixel;
        unsigned int g = (unsigned int)*(pixel + 1);
        unsigned int b = (unsigned int)*(pixel + 2);
        unsigned int a = (unsigned int)*(pixel + 3);

        if (r != 0 && g != 0 && b != 0 && a != 0)
        {
            m_bEraserOk = false;
            break;
        }
    }
    //如果改列 有一个点的像素点值不为零 跳出
    if (pRenderTexture->getContentSize().height != y)
    {
        break;
    }
}

//如果所有点的像素点值都为0 则擦除完毕
if (x == pRenderTexture->getContentSize().width && y == pRenderTexture->getContentSize().height)
{
    m_bEraserOk = true;
}

delete image;

return m_bEraserOk;

}