I created CCMenuItem elements with no ‘selected’ image (ie, set to NULL). When trying to run a CCFaceOut action on the CCMenuItem, the application crashes on null pointer access on this line:
void CCMenuItemSprite::setOpacity(GLubyte opacity)
{
m_pNormalImage->convertToRGBAProtocol()->setOpacity(opacity)
m_pSelectedImage->convertToRGBAProtocol()->setOpacity(opacity); // CRASH HERE as m_pSelectedImage is NULL
if (m_pDisabledImage)
{
m_pDisabledImage->convertToRGBAProtocol()->setOpacity(opacity);
}
}
To fix, I replaced by the following:
void CCMenuItemSprite::setOpacity(GLubyte opacity)
{
m_pNormalImage->convertToRGBAProtocol()->setOpacity(opacity);
if (m_pSelectedImage) // <--- ADDED THIS LINE
m_pSelectedImage->convertToRGBAProtocol()->setOpacity(opacity);
if (m_pDisabledImage)
{
m_pDisabledImage->convertToRGBAProtocol()->setOpacity(opacity);
}
}
Keep up the good work.
Best,