1.fixed frame event may forword emit

This commit is contained in:
kaile.yin 2014-10-23 17:37:18 +08:00
parent 400cceeae8
commit e7de544231
3 changed files with 35 additions and 34 deletions

View File

@ -79,7 +79,7 @@ VisibleFrame::VisibleFrame()
{ {
} }
void VisibleFrame::onEnter(Frame *nextFrame) void VisibleFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
_node->setVisible(_visible); _node->setVisible(_visible);
} }
@ -122,7 +122,7 @@ void TextureFrame::setNode(Node* node)
_sprite = dynamic_cast<Sprite*>(node); _sprite = dynamic_cast<Sprite*>(node);
} }
void TextureFrame::onEnter(Frame *nextFrame) void TextureFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
if(_sprite) if(_sprite)
{ {
@ -166,10 +166,10 @@ RotationFrame::RotationFrame()
{ {
} }
void RotationFrame::onEnter(Frame *nextFrame) void RotationFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
_node->setRotation(_rotation); _node->setRotation(_rotation);
if(_tween) if(_tween)
{ {
_betwennRotation = static_cast<RotationFrame*>(nextFrame)->_rotation - _rotation; _betwennRotation = static_cast<RotationFrame*>(nextFrame)->_rotation - _rotation;
@ -216,11 +216,11 @@ SkewFrame::SkewFrame()
{ {
} }
void SkewFrame::onEnter(Frame *nextFrame) void SkewFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
_node->setSkewX(_skewX); _node->setSkewX(_skewX);
_node->setSkewY(_skewY); _node->setSkewY(_skewY);
if(_tween) if(_tween)
{ {
_betweenSkewX = static_cast<SkewFrame*>(nextFrame)->_skewX - _skewX; _betweenSkewX = static_cast<SkewFrame*>(nextFrame)->_skewX - _skewX;
@ -271,11 +271,11 @@ RotationSkewFrame::RotationSkewFrame()
{ {
} }
void RotationSkewFrame::onEnter(Frame *nextFrame) void RotationSkewFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
_node->setRotationSkewX(_skewX); _node->setRotationSkewX(_skewX);
_node->setRotationSkewY(_skewY); _node->setRotationSkewY(_skewY);
if (_tween) if (_tween)
{ {
_betweenSkewX = static_cast<RotationSkewFrame*>(nextFrame)->_skewX - _skewX; _betweenSkewX = static_cast<RotationSkewFrame*>(nextFrame)->_skewX - _skewX;
@ -325,7 +325,7 @@ PositionFrame::PositionFrame()
{ {
} }
void PositionFrame::onEnter(Frame *nextFrame) void PositionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
_node->setPosition(_position); _node->setPosition(_position);
@ -378,11 +378,11 @@ ScaleFrame::ScaleFrame()
{ {
} }
void ScaleFrame::onEnter(Frame *nextFrame) void ScaleFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
_node->setScaleX(_scaleX); _node->setScaleX(_scaleX);
_node->setScaleY(_scaleY); _node->setScaleY(_scaleY);
if(_tween) if(_tween)
{ {
_betweenScaleX = static_cast<ScaleFrame*>(nextFrame)->_scaleX - _scaleX; _betweenScaleX = static_cast<ScaleFrame*>(nextFrame)->_scaleX - _scaleX;
@ -432,7 +432,7 @@ AnchorPointFrame::AnchorPointFrame()
{ {
} }
void AnchorPointFrame::onEnter(Frame *nextFrame) void AnchorPointFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
_node->setAnchorPoint(_anchorPoint); _node->setAnchorPoint(_anchorPoint);
} }
@ -469,7 +469,7 @@ InnerActionFrame::InnerActionFrame()
{ {
} }
void InnerActionFrame::onEnter(Frame *nextFrame) void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
} }
@ -505,11 +505,11 @@ ColorFrame::ColorFrame()
{ {
} }
void ColorFrame::onEnter(Frame *nextFrame) void ColorFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
_node->setOpacity(_alpha); _node->setOpacity(_alpha);
_node->setColor(_color); _node->setColor(_color);
if(_tween) if(_tween)
{ {
_betweenAlpha = static_cast<ColorFrame*>(nextFrame)->_alpha - _alpha; _betweenAlpha = static_cast<ColorFrame*>(nextFrame)->_alpha - _alpha;
@ -573,9 +573,10 @@ EventFrame::EventFrame()
{ {
} }
void EventFrame::onEnter(Frame *nextFrame) void EventFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
emitEvent(); if(currentFrameIndex>=_frameIndex)
emitEvent();
} }
@ -608,7 +609,7 @@ ZOrderFrame::ZOrderFrame()
{ {
} }
void ZOrderFrame::onEnter(Frame *nextFrame) void ZOrderFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{ {
if(_node) if(_node)
_node->setLocalZOrder(_zorder); _node->setLocalZOrder(_zorder);

View File

@ -56,7 +56,7 @@ public:
virtual bool isEnterWhenPassed() { return _enterWhenPassed; } virtual bool isEnterWhenPassed() { return _enterWhenPassed; }
virtual void onEnter(Frame *nextFrame) = 0; virtual void onEnter(Frame* nextFrame, int currentFrameIndex) = 0;
virtual void apply(float percent) {} virtual void apply(float percent) {}
virtual Frame* clone() = 0; virtual Frame* clone() = 0;
@ -84,7 +84,7 @@ public:
VisibleFrame(); VisibleFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual Frame* clone() override; virtual Frame* clone() override;
inline void setVisible(bool visible) { _visible = visible;} inline void setVisible(bool visible) { _visible = visible;}
@ -104,7 +104,7 @@ public:
virtual void setNode(cocos2d::Node* node); virtual void setNode(cocos2d::Node* node);
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual Frame* clone() override; virtual Frame* clone() override;
inline void setTextureName(std::string textureName) { _textureName = textureName;} inline void setTextureName(std::string textureName) { _textureName = textureName;}
@ -122,7 +122,7 @@ public:
RotationFrame(); RotationFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual void apply(float percent) override; virtual void apply(float percent) override;
virtual Frame* clone() override; virtual Frame* clone() override;
@ -141,7 +141,7 @@ public:
SkewFrame(); SkewFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual void apply(float percent) override; virtual void apply(float percent) override;
virtual Frame* clone() override; virtual Frame* clone() override;
@ -166,7 +166,7 @@ public:
RotationSkewFrame(); RotationSkewFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual void apply(float percent) override; virtual void apply(float percent) override;
virtual Frame* clone() override; virtual Frame* clone() override;
}; };
@ -179,7 +179,7 @@ public:
PositionFrame(); PositionFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual void apply(float percent) override; virtual void apply(float percent) override;
virtual Frame* clone() override; virtual Frame* clone() override;
@ -205,7 +205,7 @@ public:
ScaleFrame(); ScaleFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual void apply(float percent) override; virtual void apply(float percent) override;
virtual Frame* clone() override; virtual Frame* clone() override;
@ -232,7 +232,7 @@ public:
AnchorPointFrame(); AnchorPointFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual Frame* clone() override; virtual Frame* clone() override;
inline void setAnchorPoint(const cocos2d::Point& point) { _anchorPoint = point; } inline void setAnchorPoint(const cocos2d::Point& point) { _anchorPoint = point; }
@ -257,7 +257,7 @@ public:
static InnerActionFrame* create(); static InnerActionFrame* create();
InnerActionFrame(); InnerActionFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual Frame* clone() override; virtual Frame* clone() override;
inline void setInnerActionType(InnerActionType type) { _innerActionType = type; } inline void setInnerActionType(InnerActionType type) { _innerActionType = type; }
@ -278,7 +278,7 @@ public:
static ColorFrame* create(); static ColorFrame* create();
ColorFrame(); ColorFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual void apply(float percent) override; virtual void apply(float percent) override;
virtual Frame* clone() override; virtual Frame* clone() override;
@ -307,7 +307,7 @@ public:
EventFrame(); EventFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual Frame* clone() override; virtual Frame* clone() override;
inline void setEvent(std::string event) { _event = event;} inline void setEvent(std::string event) { _event = event;}
@ -324,7 +324,7 @@ public:
ZOrderFrame(); ZOrderFrame();
virtual void onEnter(Frame *nextFrame) override; virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
virtual Frame* clone() override; virtual Frame* clone() override;
inline void setZOrder(int zorder) { _zorder = zorder;} inline void setZOrder(int zorder) { _zorder = zorder;}

View File

@ -202,7 +202,7 @@ void Timeline::binarySearchKeyFrame(int frameIndex)
if(needEnterFrame || _currentKeyFrame != from) if(needEnterFrame || _currentKeyFrame != from)
{ {
_currentKeyFrame = from; _currentKeyFrame = from;
_currentKeyFrame->onEnter(to); _currentKeyFrame->onEnter(to, frameIndex);
} }
} }
@ -254,7 +254,7 @@ void Timeline::updateCurrentKeyFrame(int frameIndex)
if(frameIndex > from->getFrameIndex() && frameIndex < to->getFrameIndex()) if(frameIndex > from->getFrameIndex() && frameIndex < to->getFrameIndex())
break; break;
if(from->isEnterWhenPassed()) if(from->isEnterWhenPassed())
from->onEnter(to); from->onEnter(to, from->getFrameIndex());
} }
while (true); while (true);
@ -266,7 +266,7 @@ void Timeline::updateCurrentKeyFrame(int frameIndex)
} while (0); } while (0);
_currentKeyFrame = from; _currentKeyFrame = from;
_currentKeyFrame->onEnter(to); _currentKeyFrame->onEnter(to, frameIndex);
} }
} }