Thursday, May 28, 2015

Cocos2d-x: EXEC_BAD_ACCESS Frustum Dirty

If you get this error message:

     EXEC_BAD_ACCESS Frustum Dirty

it means that the 3D model was wrongly added to

GameScene::init()

To solve it, you need to delay the adding of the 3D model until all the other code has executed.
So, do this:

bool GameScene::init()
{
    
    if ( !Layer::init() )
    {
        return false;
    }

    //  Add all your 2D Sprites here

    this->scheduleOnce(schedule_selector(GameScene::Init3DScene), 0.1f);

    return true;
}

void GameScene::Init3DScene(float dt){
    //  Add all your 3D Sprite models here
    auto girl = Sprite3D::create("girl.c3b");

    this->addChild(girl);
}

No comments:

Post a Comment