Return to Cocos2dx Playback Library

Problems with create cache with gaf assets

Questions related to Cocos2dx playback library should be asked here.

Problems with create cache with gaf assets

Postby Mike Derevyannykh » December 13th, 2015, 11:54 am

Hi. I create std::map<std::string, gaf::GafAsset*> cache in game during loading game resources.

std::map<std::string, gaf::GAFAsset*> Cache::animations;

void Cache::loadAnimation(std::string name){
animations.insert(std::make_pair(name, gaf::GAFAsset::create(Settings::AnimationPath + name)));
}

After loading all the resources I create a game scene where I consistently try to create multiple objects from the cache and unload the desired animated texture.

gaf::GAFAsset* Cache::getAnimationAtlas(std::string name){
return animations[name];
}

AObject - class of Animated Object. This class inherits from class GafObject.

AObject::AObject(AObjectSett settings)
{
auto Atlas = Cache::getAnimationAtlas(settings.GAFFile);
init(Atlas, Atlas->getRootTimeline());
...
}

But i have error. TimeLine == NULL. And another objects, points of atlases = NULL.
What am I doing wrong?
Thanks.
User avatar
Mike Derevyannykh
 
Posts: 7
Joined: November 17th, 2015, 4:20 am

Re: Problems with create cache with gaf assets

Postby Dmitry Bushtets » December 14th, 2015, 4:09 am

Hi!
Can you provide sample class so we can check this issue on our side.

And, just in case, check:
1. Cache::getAnimationAtlas . operator[] can return empty GAFAsset* if no keys found. Maybe it can be replaced with find()
2. Maybe you need ->retain() for GAFAsset instance in map
User avatar
Dmitry Bushtets
 
Posts: 86
Joined: August 11th, 2014, 1:31 am

Re: Problems with create cache with gaf assets

Postby Mike Derevyannykh » December 14th, 2015, 5:52 am

Thanks. Second resolve helped me.
User avatar
Mike Derevyannykh
 
Posts: 7
Joined: November 17th, 2015, 4:20 am

Return to Cocos2dx Playback Library

Who is online

Users browsing this forum: No registered users and 1 guest