How does cocostudio::ActionManagerEx::getInstance()->playActionByName();
know which node to animate?
I have:
Layout *layout = dynamic_cast<Layout*>(cocostudio::GUIReader::shareReader()->widgetFromJsonFile("Dialog_1.json"));
cocostudio::ActionManagerEx::getInstance()->playActionByName("Dialog_1.json", "Animation1");
It works fine but i wonder how does it know which node to animate “layout”
iQD
July 28, 2014, 1:14pm
#2
Take a look into cocostudio/CCSGUIReader.cpp
Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, const char* fullPath, const char* fileName)
When you are loading in the json definition file it creates the widgets and inits the ActionManagerEx with them:
ActionManagerEx::getInstance()->initWithDictionary(fileName,actions,rootWidget);
Which creates the actions itself and binds/links them to the widgets/nodes.
cocostudio::ActionManagerEx::getInstance()->playActionByName("Dialog_1.json", "Animation1");
This call looks up the “Dialog_1.json” actions as key from the action dictionary in the ActionManagerEx and calls the “Animation1”.
As it has created the actions and linked the nodes beforehand it “knows” which node to animate in “layout”.
1 Like
and how do I remove / release widget from GUIReader?
There are no member functions in GuiReader for that.
iQD
July 28, 2014, 3:31pm
#5
By removing it from the layout. Layout is the root widget aka the parent of all other widgets:
void removeChild (Node *child, bool cleanup=true);
First you get the pointer for your node, which you want to remove and than call the above function with that pointer.