diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp index a959680716..bcd9c0cbca 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp @@ -570,12 +570,22 @@ void EventFrame::init() EventFrame::EventFrame() : _event("") + , _action(nullptr) { } +void EventFrame::setNode(cocos2d::Node* node) +{ + Frame::setNode(node); + _action = _timeline->getActionTimeline(); +} + void EventFrame::onEnter(Frame *nextFrame, int currentFrameIndex) { - if(currentFrameIndex>=_frameIndex) + if(_frameIndex<_action->getStartFrame() || _frameIndex>_action->getEndFrame()) + return; + + if(currentFrameIndex >= _frameIndex) emitEvent(); } diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h index 2be52adfb4..e5d411f159 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h @@ -37,6 +37,7 @@ THE SOFTWARE. NS_TIMELINE_BEGIN class Timeline; +class ActionTimeline; class CC_STUDIO_DLL Frame : public cocos2d::Ref { @@ -307,6 +308,8 @@ public: EventFrame(); + virtual void setNode(cocos2d::Node* node); + virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override; virtual Frame* clone() override; @@ -315,6 +318,7 @@ public: protected: std::string _event; + ActionTimeline* _action; }; class CC_STUDIO_DLL ZOrderFrame : public Frame