Get access to the CCBanimationManager instance

Hi, I’m trying to get access to the CCBanimationManager from a custom class linked between the cocosbuilder scene and the cocos2d-x code.

In objective-c this should be easy, but it doesn’t work in Cocos2d-x (bug?) (missing feature?)

CCBAnimationManager* animationManager = self.userObject;

the same in C++ returns always a NULL value
CCBAnimationManager* anim= static_cast<CCBAnimationManager*>(node->getUserObject());

Any idea? Thanks.

just to make it clear, the problem is that in Cocos2D it is very easy to get the reference to the CCBAnimationManager, and as far as I know there is no way to do the same with Cocos2D-X

Any suggestion?

I looked at the test code and figured it out. This is what I am doing:

@ auto mgr = reader->getAnimationManager();@

The reader is a CCBReader? I have access to it from the Scene, but not from custom classes linked to cocosbuilder, do you?

Thks

Somewhere in your code, you construct a CCBReader. Then you use the reader to load your CCBI file. That is where you get access to the AnimationManager. After loading the Scene, you can do whatever you need to do with custom classes. For example, you can search the scene graph for custom classes, and assign the AnimationManager to it, if that is what you want.

I just keep a reference to it in my class that manages the game world.

mmm I construct a CCBReader, and can pass the CCBAnimationManager to the Layer, but if I do this, I can’t run an animation defined in a sub CCBFile.

Imagine that I have the animationManager in my Layer, and this layer contains a sub CCBFile with the tag 5, and it has a timeline called “hammer” that I want to play, how do you do this? If I do this:

CCNode* child = this~~>getChildByTag; // This is NOT null
this~~>animationManager~~>setRootNode;
this~~>animationManager->runAnimations(“hammer”);

The result of this is that “Sequence id couldn’t be found”.

Any idea? Thanks!

this might be that I’m doing it wrong, but I believe that CCBReader has some kind of bug or missing feature that is to be able to read sub-sequences… (this can be done in Cocos2D for iPhone)

Hey Jesus,

Did you get solution to this problem? I am looking for the same.

Thanks,
Paras

http://www.cocos2d-x.org/boards/6/topics/17691?r=17882#message-17882