I create a sprite and add to scene in the Scene Init fucntion - No problem
I then do a duplicate process with a external class and get nullptr error- no idea why
I have done these things before so cant figure out why error
auto layer = cocos2d::Layer::create();
this->addChild(layer, 3);
cocos2d::Sprite* sprite = cocos2d::Sprite::create("Agent/dot.png");
layer->addChild(sprite, 1);// NO PROBLEM
gaddbox->init();
layer->addChild(gaddbox->getSprite(), 1);// PROBLEM
Are you positive you are using the code as you paste it here ?
are you sure you are calling :
gaddbox->init();
layer->addChild(gaddbox->getSprite(), 1);// PROBLEM
right after ? or could it be you are doing that inside a lambada function ?
If it is inside a lambada function cocos will recognize your sprite is not in use and will release its memory.
alos I am not quite sure what did you mean :
sprite = cocos2d::Sprite::create(“Agent/dot.png”);//DEBUGGER SAYS “write access violation, This was nullptr”