I could keep label reference in a member variable, but I preferred to manage it in the layer structure. So far I found the only api to get children is layer->getChildByXxx. They all return Node*. I get Label is descendant of Node as it can be added as a child of layer. So I did this.
label->setName("label");
// add the label as a child to this layer
this->addChild(label, 1);
and
auto label = dynamic_cast<Label*>(this->getChildByName("label"));
It works so far. Correct me if there is a better way.
No comments:
Post a Comment