fixed frame event

This commit is contained in:
youyou 2014-12-12 18:02:03 +08:00
parent e060360d9b
commit 579bb3f8d8
2 changed files with 15 additions and 1 deletions

View File

@ -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();
}

View File

@ -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