Exemplo n.º 1
0
static void foreachNodeDescendant(Node* parent, std::function<void(Node*)> callback)
{
    callback(parent);

    auto& children = parent->getChildren();
    for (auto child : children)
    {
        foreachNodeDescendant(child, callback);
    }
}
void foreachNodeDescendant(Node* parent, tCallBack callback)
{
    callback(parent);

    auto& children = parent->getChildren();
    for (auto child : children)
    {
        foreachNodeDescendant(child, callback);
    }
}
void ActionTimeline::startWithTarget(Node *target)
{
    Action::startWithTarget(target);

    foreachNodeDescendant(target, 
        [this, target](Node* child)
    {
        ActionTimelineData* data = dynamic_cast<ActionTimelineData*>(child->getUserObject());
        int actionTag = data->getActionTag();
        if(_timelineMap.find(actionTag) != _timelineMap.end())
        {
            auto timelines = this->_timelineMap[actionTag];
            for (auto timeline : timelines)
            {
                timeline->setNode(child);
            }
        }
    });
}
void ActionTimeline::startWithTarget(Node *target)
{
    Action::startWithTarget(target);
    this->setTag(target->getTag());

    foreachNodeDescendant(target, 
        [this, target](Node* child)
    {
        ComExtensionData* data = dynamic_cast<ComExtensionData*>(child->getComponent("ComExtensionData"));

        if(data)
        {
            int actionTag = data->getActionTag();
            if(_timelineMap.find(actionTag) != _timelineMap.end())
            {
                auto timelines = this->_timelineMap[actionTag];
                for (auto timeline : timelines)
                {
                    timeline->setNode(child);
                }
            }
        }
    });
}