mirror of https://github.com/axmolengine/axmol.git
Fix when add two ActionTimeLine object in one node, play state is wrong
This commit is contained in:
parent
9c86d1f0f1
commit
0f3cb16efd
|
@ -164,6 +164,16 @@ ActionTimeline* ActionTimelineCache::createActionFromJson(const std::string& fil
|
||||||
return action->clone();
|
return action->clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActionTimeline* ActionTimelineCache::createActionFromContent(const std::string& fileName, const std::string& content)
|
||||||
|
{
|
||||||
|
ActionTimeline* action = _animationActions.at(fileName);
|
||||||
|
if (action == nullptr)
|
||||||
|
{
|
||||||
|
action = loadAnimationActionWithContent(fileName, content);
|
||||||
|
}
|
||||||
|
return action->clone();
|
||||||
|
}
|
||||||
|
|
||||||
ActionTimeline* ActionTimelineCache::loadAnimationActionWithFile(const std::string& fileName)
|
ActionTimeline* ActionTimelineCache::loadAnimationActionWithFile(const std::string& fileName)
|
||||||
{
|
{
|
||||||
// Read content from file
|
// Read content from file
|
||||||
|
@ -403,7 +413,7 @@ Frame* ActionTimelineCache::loadZOrderFrame(const rapidjson::Value& json)
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersFile(const std::string &fileName)
|
ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersFile(const std::string &fileName)
|
||||||
{
|
{
|
||||||
ActionTimeline* action = _animationActions.at(fileName);
|
ActionTimeline* action = _animationActions.at(fileName);
|
||||||
|
@ -414,6 +424,16 @@ ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersFile(const std::
|
||||||
return action->clone();
|
return action->clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActionTimeline* ActionTimelineCache::createActionWithDataBuffer(Data data, const std::string &fileName)
|
||||||
|
{
|
||||||
|
ActionTimeline* action = _animationActions.at(fileName);
|
||||||
|
if (action == NULL)
|
||||||
|
{
|
||||||
|
action = loadAnimationWithDataBuffer(data, fileName);
|
||||||
|
}
|
||||||
|
return action->clone();
|
||||||
|
}
|
||||||
|
|
||||||
ActionTimeline* ActionTimelineCache::loadAnimationActionWithFlatBuffersFile(const std::string &fileName)
|
ActionTimeline* ActionTimelineCache::loadAnimationActionWithFlatBuffersFile(const std::string &fileName)
|
||||||
{
|
{
|
||||||
// if already exists an action with filename, then return this action
|
// if already exists an action with filename, then return this action
|
||||||
|
|
|
@ -78,11 +78,14 @@ public:
|
||||||
|
|
||||||
/** Clone a action with the specified name from the container. */
|
/** Clone a action with the specified name from the container. */
|
||||||
ActionTimeline* createActionFromJson(const std::string& fileName);
|
ActionTimeline* createActionFromJson(const std::string& fileName);
|
||||||
|
ActionTimeline* createActionFromContent(const std::string& fileName, const std::string& content);
|
||||||
|
|
||||||
ActionTimeline* loadAnimationActionWithFile(const std::string& fileName);
|
ActionTimeline* loadAnimationActionWithFile(const std::string& fileName);
|
||||||
ActionTimeline* loadAnimationActionWithContent(const std::string&fileName, const std::string& content);
|
ActionTimeline* loadAnimationActionWithContent(const std::string&fileName, const std::string& content);
|
||||||
|
|
||||||
ActionTimeline* createActionWithFlatBuffersFile(const std::string& fileName);
|
ActionTimeline* createActionWithFlatBuffersFile(const std::string& fileName);
|
||||||
|
ActionTimeline* createActionWithDataBuffer(cocos2d::Data data, const std::string &fileName);
|
||||||
|
|
||||||
ActionTimeline* loadAnimationActionWithFlatBuffersFile(const std::string& fileName);
|
ActionTimeline* loadAnimationActionWithFlatBuffersFile(const std::string& fileName);
|
||||||
ActionTimeline* loadAnimationWithDataBuffer(const cocos2d::Data data, const std::string fileName);
|
ActionTimeline* loadAnimationWithDataBuffer(const cocos2d::Data data, const std::string fileName);
|
||||||
|
|
||||||
|
|
|
@ -356,12 +356,12 @@ ActionTimeline* CSLoader::createTimeline(const Data data, const std::string& fil
|
||||||
|
|
||||||
if (suffix == "csb")
|
if (suffix == "csb")
|
||||||
{
|
{
|
||||||
return cache->loadAnimationWithDataBuffer(data, filename);
|
return cache->createActionWithDataBuffer(data, filename);
|
||||||
}
|
}
|
||||||
else if (suffix == "json" || suffix == "ExportJson")
|
else if (suffix == "json" || suffix == "ExportJson")
|
||||||
{
|
{
|
||||||
std::string content((char *)data.getBytes(), data.getSize());
|
std::string content((char *)data.getBytes(), data.getSize());
|
||||||
return cache->loadAnimationActionWithContent(filename, content);
|
return cache->createActionFromContent(filename, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1016,7 +1016,7 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const
|
||||||
{
|
{
|
||||||
Data buf = FileUtils::getInstance()->getDataFromFile(filePath);
|
Data buf = FileUtils::getInstance()->getDataFromFile(filePath);
|
||||||
node = createNode(buf, callback);
|
node = createNode(buf, callback);
|
||||||
action = timeline::ActionTimelineCache::getInstance()->loadAnimationWithDataBuffer(buf, filePath);
|
action = createTimeline(buf, filePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@ CocoStudioActionTimelineTests::CocoStudioActionTimelineTests()
|
||||||
ADD_TEST_CASE(TestActionTimelineBlendFuncFrame);
|
ADD_TEST_CASE(TestActionTimelineBlendFuncFrame);
|
||||||
ADD_TEST_CASE(TestAnimationClipEndCallBack);
|
ADD_TEST_CASE(TestAnimationClipEndCallBack);
|
||||||
ADD_TEST_CASE(TestActionTimelinePlayableFrame);
|
ADD_TEST_CASE(TestActionTimelinePlayableFrame);
|
||||||
|
ADD_TEST_CASE(TestActionTimelineIssueWith2SameActionInOneNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
CocoStudioActionTimelineTests::~CocoStudioActionTimelineTests()
|
CocoStudioActionTimelineTests::~CocoStudioActionTimelineTests()
|
||||||
|
@ -742,3 +743,21 @@ std::string TestActionTimelinePlayableFrame::title() const
|
||||||
{
|
{
|
||||||
return "Test Action Timeline PlayableFrame\n particle and audio";
|
return "Test Action Timeline PlayableFrame\n particle and audio";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestActionTimelineIssueWith2SameActionInOneNode::onEnter()
|
||||||
|
{
|
||||||
|
CCFileUtils::getInstance()->addSearchPath("ActionTimeline");
|
||||||
|
ActionTimelineBaseTest::onEnter();
|
||||||
|
|
||||||
|
Node* node = CSLoader::createNode("ani2.csb");
|
||||||
|
ActionTimeline* action = CSLoader::createTimeline("ani2.csb");
|
||||||
|
node->setPosition(Vec2(150, 100));
|
||||||
|
node->runAction(action);
|
||||||
|
action->gotoFrameAndPlay(0);
|
||||||
|
this->addChild(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string TestActionTimelineIssueWith2SameActionInOneNode::title() const
|
||||||
|
{
|
||||||
|
return "Add multi same action in one node issue\n These two actions should play async.";
|
||||||
|
}
|
|
@ -164,4 +164,14 @@ public:
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TestActionTimelineIssueWith2SameActionInOneNode : public ActionTimelineBaseTest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CREATE_FUNC(TestActionTimelineIssueWith2SameActionInOneNode);
|
||||||
|
|
||||||
|
virtual void onEnter() override;
|
||||||
|
virtual std::string title() const override;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // __ANIMATION_SCENE_H__
|
#endif // __ANIMATION_SCENE_H__
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -52,7 +52,7 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*
|
||||||
ActionNode::[initWithDictionary],
|
ActionNode::[initWithDictionary],
|
||||||
ActionObject::[initWithDictionary initWithBinary],
|
ActionObject::[initWithDictionary initWithBinary],
|
||||||
BaseData::[copy subtract],
|
BaseData::[copy subtract],
|
||||||
ActionTimelineCache::[getInstance loadActionTimelineFromXML loadAnimationWithDataBuffer],
|
ActionTimelineCache::[getInstance loadActionTimelineFromXML loadAnimationWithDataBuffer createActionWithDataBuffer],
|
||||||
ActionTimeline::[setFrameEventCallFunc]
|
ActionTimeline::[setFrameEventCallFunc]
|
||||||
|
|
||||||
rename_functions = ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyInstance],
|
rename_functions = ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyInstance],
|
||||||
|
|
Loading…
Reference in New Issue