Пример #1
0
NS_TIMELINE_BEGIN

// ActionTimelineData
ActionTimelineData* ActionTimelineData::create(int actionTag)
{
    ActionTimelineData * ret = new (std::nothrow) ActionTimelineData();
    if (ret && ret->init(actionTag))
    {
        ret->autorelease();
        return ret;
    }
    
    delete ret;
    return nullptr;
}
NS_TIMELINE_BEGIN

// ActionTimelineData
ActionTimelineData* ActionTimelineData::create(int actionTag)
{
    ActionTimelineData * ret = new (std::nothrow) ActionTimelineData();
    if (ret && ret->init(actionTag))
    {
        ret->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(ret);
    }
    return ret;
}
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);
            }
        }
    });
}