Update 1: Bottom of this post
Update 2: A reply of this post
Update 3: Post#8
Hi everyone, I am getting this error at run time.
I will try to simplify this by showing only relevant code.
I am extending my People class to cocos2d::Node so I can attempt to have multiple objects update themselves. In other words, call scheduleUpdate in every object. Since each node can only have 1 update function, this is my attempt to do it. Is this ok? (Instead, I can have update of layer call EVERY objectās update function, but I want to release this dependency and let objects handle themselves.)
People.h constructor
People(int h, std::string n, const std::string& filename, Layer* layer);
People.cpp constructor
#include "People.h"
//base class People
People::People(int h, std::string n, const std::string& filename, cocos2d::Layer* layer){
sprite = cocos2d::Sprite::create(filename);
this->addChild(sprite,0);
layer->addChild(this,5); //'this' is causing the error **UPDATE BELOW**
}
bool People::init(){
CCLOG("ppl init");
return true;
}
void People::update(float dt){
CCLOG("PEOPLE reached");
}
Call
People d(20, āPeopleā, āa.pngā,this); //āthisā is a CCLayer
Can someone point me in the right direction?
Update 1: It turns out that this line gets executed fine, in fact the objects initialization is perfectly fine, but on the program gives an error at CCNODE.cpp ,
// MARK: events
void Node::onEnter()
{
if (_onEnterCallback)
_onEnterCallback();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
if (ScriptEngineManager::sendNodeEventToJS(this, kNodeOnEnter))
return;
}
#endif
_isTransitionFinished = false;
for( const auto &child: _children)
child->onEnter(); //causing error here.
this->resume();
_running = true;
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeLua)
{
ScriptEngineManager::sendNodeEventToLua(this, kNodeOnEnter);
}
#endif
}
I tried to debug it up to this point, but I am unable to do so at the moment. Does anyone know what is going on?