I have a class derived from Node
with update(float)
hooks overriden in it. Does I need to call scheduleUpdate
on each object of that class or I can make it recursive on Scene
children? What is the reason to call scheduleUpdate
on Scene
if children can “receive” hooks if I simply call schedule on them not touching Scene
?
If I want to run update on each child of given object should I override scheduleUpdate
method of that class?
p.s. looking at unity3d each game object can receive lifecycle hooks by default when created. In cocos2dx programmer decide when run them on his own?
I do it for each class that need it.
Do you want the same update to happen in all objects every frame?
You need to make a base class with scheduleUpdate enabled… then use this base class for the children. You can override the children update method. but avoid redundancy… try to put as much as possible in the base class.
This is a great way except the base class must inherit from Ref at least I believe.
I already have done GameObject
class derived from Node
and Node
private field in it to hack cocos2dx architecture adding an intermediate class between Node
and Sprite
/Label
/…/etc. classes derived from Node
and I have a lot of issues now
Thanks for the response
Do you do that in class init
method? Not on concrete objects?