mirror of https://github.com/axmolengine/axmol.git
fix bug: #23532 AnchorPointFrame animation performance diffrent with cocos studio
This commit is contained in:
parent
f4a2a53f6d
commit
be8a158bd7
|
@ -478,17 +478,23 @@ inline ActionTimeline* ActionTimelineCache::createActionWithDataBuffer(const coc
|
||||||
action->addAnimationInfo(info);
|
action->addAnimationInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto timelines = nodeAction->timeLines();
|
auto timeLines = nodeAction->timeLines();
|
||||||
int timelineLength = timelines->size();
|
int timelineLength = timeLines->size();
|
||||||
|
std::multimap<std::string, cocostudio::timeline::Timeline*> properTimelineMap;// order the timelines depends property name
|
||||||
for (int i = 0; i < timelineLength; i++)
|
for (int i = 0; i < timelineLength; i++)
|
||||||
{
|
{
|
||||||
auto timelineFlatBuf = timelines->Get(i);
|
auto timelineFlatBuf = timeLines->Get(i);
|
||||||
Timeline* timeline = loadTimelineWithFlatBuffers(timelineFlatBuf);
|
Timeline* timeline = loadTimelineWithFlatBuffers(timelineFlatBuf);
|
||||||
|
|
||||||
if (timeline)
|
if (timeline)
|
||||||
action->addTimeline(timeline);
|
{
|
||||||
|
properTimelineMap.insert(std::make_pair(timelineFlatBuf->property()->c_str(), timeline));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& properTimelinePair : properTimelineMap)
|
||||||
|
{
|
||||||
|
action->addTimeline(properTimelinePair.second);
|
||||||
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -969,17 +975,22 @@ ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(con
|
||||||
|
|
||||||
auto timeLines = nodeAction->timeLines();
|
auto timeLines = nodeAction->timeLines();
|
||||||
int timelineLength = timeLines->size();
|
int timelineLength = timeLines->size();
|
||||||
|
std::multimap<std::string, cocostudio::timeline::Timeline*> properTimelineMap;// order the timelines depends property name
|
||||||
for (int i = 0; i < timelineLength; i++)
|
for (int i = 0; i < timelineLength; i++)
|
||||||
{
|
{
|
||||||
auto timelineFlatBuf = timeLines->Get(i);
|
auto timelineFlatBuf = timeLines->Get(i);
|
||||||
Timeline* timeline = loadTimelineWithFlatBuffers(timelineFlatBuf);
|
Timeline* timeline = loadTimelineWithFlatBuffers(timelineFlatBuf);
|
||||||
|
|
||||||
if (timeline)
|
if (timeline)
|
||||||
action->addTimeline(timeline);
|
{
|
||||||
|
properTimelineMap.insert(std::make_pair(timelineFlatBuf->property()->c_str(), timeline));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& properTimelinePair : properTimelineMap)
|
||||||
|
{
|
||||||
|
action->addTimeline(properTimelinePair.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
fbs->deleteFlatBufferBuilder();
|
fbs->deleteFlatBufferBuilder();
|
||||||
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -506,7 +506,10 @@ void AnchorPointFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (_tween)
|
||||||
|
{
|
||||||
|
_betweenAnchorPoint = static_cast<AnchorPointFrame*>(nextFrame)->_anchorPoint - _anchorPoint;
|
||||||
|
}
|
||||||
_node->setAnchorPoint(_anchorPoint);
|
_node->setAnchorPoint(_anchorPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,6 +524,15 @@ Frame* AnchorPointFrame::clone()
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnchorPointFrame::onApply(float percent)
|
||||||
|
{
|
||||||
|
if ((nullptr != _node) && (_betweenAnchorPoint.x != 0 || _betweenAnchorPoint.y != 0))
|
||||||
|
{
|
||||||
|
auto applyAnchorP = _betweenAnchorPoint * percent + _anchorPoint;
|
||||||
|
_node->setAnchorPoint(applyAnchorP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// InnerActionFrame
|
// InnerActionFrame
|
||||||
|
|
|
@ -260,7 +260,10 @@ public:
|
||||||
inline cocos2d::Point getAnchorPoint() const { return _anchorPoint; }
|
inline cocos2d::Point getAnchorPoint() const { return _anchorPoint; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
cocos2d::Point _anchorPoint;
|
virtual void onApply(float percent) override;
|
||||||
|
|
||||||
|
cocos2d::Vec2 _betweenAnchorPoint;
|
||||||
|
cocos2d::Vec2 _anchorPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue