A very weird error

Hi everyone, I’m quite new to C++ and also new to this forums. I’ve no clue what should I search for, thus I create a thread for this.
I’m not sure whether this is a very simple problem or not, it just don’t make sense to me.

Here’s my problem: (look at the image attached)

http://goo.gl/ajAdm (in case you cannot see the image, I provided a link here)

When the program reaches entity->parseOptionalData(object); it ‘flies’ to cocos2d::CCSprite::setColor()
the method Entity::parseOptionalData() wasn’t called at all.

The subclass of class Entity doesn’t override the method parseOptionalData.

Some extra Information:
1.) I was using cocos2dx 2.0.3, and then I’ve also tried the lastest cocos2dx from here https://github.com/cocos2d/cocos2d-x
2.) I’m building on a BlackBerry 10 dev alpha device(OS ver 10.0.9.1675), using BB10 SDK 10.0.9.386

What I’ve tried:
1.) Change the method name “parseOptionalData” to other name
2.) Try CCLog on Entity::parseOptionalData() but nothing was logged

Anyone have any clues what is actually going on?

Thanks for spending your time reading this.


error.png (106.4 KB)

it “flies” there?
like it runs the wrong function?

have you tried setting a breakpoint on this line and clicking “step into” button to follow the logic?

daniel fountain wrote:

it “flies” there?
like it runs the wrong function?
>
have you tried setting a breakpoint on this line and clicking “step into” button to follow the logic?

Thanks for your reply!

Yes, it gets into the wrong function as displayed in the image provided.

Setting a breakpoint and “step into” also goes in to this function cocos2d::CCSprite::setColor().

Thanks!

Could you post the whole function? I believe you are inside a while loop or something.

Lance Gray wrote:

Could you post the whole function? I believe you are inside a while loop or something.

Hi Lance, thanks for replying,
this is the whole function:

void TiledLayer::addObjectsFromTileMap(CCTMXTiledMap *tileMap, TileLayerInitialData *data)
{
    CCTMXObjectGroup *objectGroup = tileMap->objectGroupNamed(OBJECT_LAYER);
    CCObject *obj = NULL;
    CCARRAY_FOREACH(objectGroup->getObjects(), obj)
    {
        CCDictionary *object = (CCDictionary *)obj;
        object->retain();
        CCString *name = (CCString *)object->objectForKey("name");
        int x = ((CCString *)object->objectForKey("x"))->intValue();
        int y = ((CCString *)object->objectForKey("y"))->intValue();
        int width = ((CCString *)object->objectForKey("width"))->intValue();
        int height = ((CCString *)object->objectForKey("height"))->intValue();

        CCPoint objectOriginPosition = CCPoint(x, y);
        CCPoint objectPosition = this->getCenterPointWithBottomLeftPoint(objectOriginPosition, height, width);
        CCString *type = (CCString *)object->objectForKey("type");
        Entity *entity = ObjectFactory::objectWithStringType(type);
        entity->retain();

        if(entity == NULL)
        {
            CCLog("The Entity %s with the Type %s is NULL.", name->getCString(), type->getCString());
            continue;
        }

        entity->setPosition(objectPosition);
        entity->name = name;

        this->tagDictionary->setObject(CCString::createWithFormat("%d", this->tagIndex), name->getCString());
        int zOrder = 1;

        if(name->compare("Player") == 0 ||
                name->compare("PlayerShadow") == 0 ||
                name->compare("ShadowRangeIndicator") == 0 ||
                name->compare("Title") == 0)
            zOrder = 2;

        if(data)
            entity = data->setInitialDataForSelectedEntity(entity);

        entity->parseOptionalData(object);

        //initType is set during parseOptionalData:
        if(entity->initType->compare(INIT_TYPE_SCENE) == 0)
            entity->setVisible(true);
        else
            entity->setVisible(false);

        //TODO required to preloadSoundEffect from Game class
//      if(entity->isRequiredPreloadSound())

        this->addChild(entity, zOrder, this->tagIndex);

        object->release();
        entity->release();

        tagIndex++;
    }
}