Cocostudio 2.3 with C++ implantation questions

Hi guys i’m pretty new to cocos2dx but not to game development so most of the time i know what i’m doing :smile:
I have watched pretty much all the tutorials by @SonarSystems which by the way where great and gave me a good head start, so thanks.
but i couldn’t find couple of things any where (searched the forums,cpp tests,api guide by solarSystems…etc’)
so i’m pretty frustrated about this please give me a hand :pensive:

so i have created a scene in Cocostudio which has Node objects which are built of sprites and other controls, and some animation to those Node object.

the first issue i had is how do i implements the behavior to those Node objects, so what i have done was to create a new class with inherits from the node and implemented and update function, and to the contractor i passed the object which i got from the scene using (Node*)rootNode->getChildByName(NODE_NAME)
the code for the class is like this: http://pastebin.com/6eMLEKuq
and in the main scene class at the init method i have added the MyNode object using addChild(), and it works fine but i’m not sure that is how i suppose to implement this because i saw that every class the inherits from cocos2d class has CREATE_FUNC() and init(), which i still can’t understand what it suppose to do exactly ,is a constructor?! :pensive:

the second thing is accessing the animations which where created in Cocostduio from all the classes, so i created a class witch has the rootNode and methods to play the animation it look like this: http://pastebin.com/ZgYXp7Ay
but after i run the action i try to access the actions thru rootNode->getActionByTag(actionTag); in order to break the loop animation ,but it returns a action type and not ActionTimeline, so to bypass this i need to create and store all the new action in list or array of type ActionTimeline, is there another why?

thanks for giving it time to read it’s pretty long.

Check out ComController for your first issue. I used it to add behaviors to my Nodes from the CSB files.

As for the second issue, you can cast the Action type to ActionTimeline and stop the animation, but make sure that the Action returned is really an ActionTimeline.

thnx @duracellrabbid the ComController was just what i was looking for, didn’t notices there was a test of this class.
just one thing when i add the controller to the node object i don’t want it to fire the update function right away, is there a way to remove it from the scheduler besides an if statement in the update function that prevents the code execution?

about the casting i will try it after i finish converting my classes to controllers.

Typically, I used a flag to prevent the code execution, but you can override the onEnter() function and don’t call the super class’ onEnter(). It will stop the update() from triggering.

great thnx @duracellrabbid, how about stoping the update loop after it started? without using a flag

about the getActionByTag(actionTag) i always get null, don’t know why

If you just want to fire an action once after it starts, then just don’t execute any code in the update loop. Use a CallFunc.

No that isn’t what i meant, i mean lets say i have a ComController class assaigned to a node, and it executes the update function as it meant to do,but after some kind of trigger,lets say a touch event i want to remove just the update function from it’s owener, i know i can use some kind of flag in the update function,but it won’t prevent it from executing every frame

After looking at the source code:

the ComController update function is triggered in the owner’s own update function (Node::update()). So if you want to stop it, you need to call Node::unscheduleUpdate() to stop it. This is the only way I know. The downside is, if you have other controller running on the Node, their update will stop as well.