For some reason this has stopped working. He worked the last time I worked on a project, but now it’s not. I double checked that it is spaceCannonTitle.pngincluded in the project. But it throws an exception to the setPosition line, because title_sprite is null.
bool MenuScene::init()
{
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
auto title_sprite = cocos2d::Sprite::create( "spaceCannonTitle.png" );
title_sprite->setPosition( Point( visibleSize.width / 2 + origin.x, visibleSize.height - title_sprite->getContentSize( ).height ) );
this->addChild( title_sprite );
...
}
EDIT: If I comment on title_sprite, this is not a failure, but I do not see the menu, and I get this error:
libpng error: CgBI: unhandled critical chunk
source
share