mirror of https://github.com/axmolengine/axmol.git
Merge pull request #10244 from geron-cn/fixProjectNodeLoader
Fix project node crash in simulator and add its test-cpp
This commit is contained in:
commit
34c132280e
|
@ -839,7 +839,6 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree)
|
||||||
{
|
{
|
||||||
node = createNodeWithFlatBuffersFile(filePath);
|
node = createNodeWithFlatBuffersFile(filePath);
|
||||||
action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
|
action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1171,9 +1170,8 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
|
||||||
cocostudio::timeline::ActionTimeline* action = nullptr;
|
cocostudio::timeline::ActionTimeline* action = nullptr;
|
||||||
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
|
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
|
||||||
{
|
{
|
||||||
node = createNodeWithFlatBuffersFile(filePath);
|
node = createNodeWithFlatBuffersForSimulator(filePath);
|
||||||
action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
|
action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,17 @@ Layer *CreateAnimationLayer(int index)
|
||||||
case TEST_TIMELINE_PERFORMACE:
|
case TEST_TIMELINE_PERFORMACE:
|
||||||
pLayer = new (std::nothrow) TestTimelinePerformance();
|
pLayer = new (std::nothrow) TestTimelinePerformance();
|
||||||
break;
|
break;
|
||||||
|
case TEST_TIMELINEACTION_ANIMATIONLIST:
|
||||||
|
pLayer = new (std::nothrow) TestTimelineAnimationList();
|
||||||
|
break;
|
||||||
|
case TEST_TIMELINEPROJECTNODE:
|
||||||
|
pLayer = new (std::nothrow) TestTimelineProjectNode();
|
||||||
|
break;
|
||||||
|
case TEST_PROJECTNODEFORSIMALATOR:
|
||||||
|
pLayer = new (std::nothrow) TestProjectNodeForSimulator;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
CCLOG("NONE OF THIS TEST LAYER");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +195,8 @@ void ActionTimelineTestLayer::nextCallback(Ref *pSender)
|
||||||
void ActionTimelineTestLayer::backCallback(Ref *pSender)
|
void ActionTimelineTestLayer::backCallback(Ref *pSender)
|
||||||
{
|
{
|
||||||
Scene *s = new (std::nothrow) ActionTimelineTestScene();
|
Scene *s = new (std::nothrow) ActionTimelineTestScene();
|
||||||
s->addChild( BackAnimationTest() );
|
auto a = BackAnimationTest();
|
||||||
|
s->addChild( a);
|
||||||
Director::getInstance()->replaceScene(s);
|
Director::getInstance()->replaceScene(s);
|
||||||
s->release();
|
s->release();
|
||||||
}
|
}
|
||||||
|
@ -324,3 +335,73 @@ std::string TestTimelinePerformance::title() const
|
||||||
return "Test ActionTimeline performance";
|
return "Test ActionTimeline performance";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestTimelineAnimationList
|
||||||
|
void TestTimelineAnimationList::onEnter()
|
||||||
|
{
|
||||||
|
ActionTimelineTestLayer::onEnter();
|
||||||
|
Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb");
|
||||||
|
ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb");
|
||||||
|
cocostudio::timeline::AnimationInfo standinfo("stand", 0, 40);
|
||||||
|
cocostudio::timeline::AnimationInfo walkinfo("walk", 41, 81)
|
||||||
|
action->addAnimationInfo(standinfo);
|
||||||
|
action->addAnimationInfo(walkinfo);
|
||||||
|
node->runAction(action);
|
||||||
|
action->play("walk", true);
|
||||||
|
|
||||||
|
node->setScale(0.2f);
|
||||||
|
node->setPosition(150,100);
|
||||||
|
addChild(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string TestTimelineAnimationList::title() const
|
||||||
|
{
|
||||||
|
return "Test ActionTimeline AnimationList";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TestTimelineProjectNode
|
||||||
|
//InnerActionFrame make InnerAction Play until action's duration or next InnerActionFrame
|
||||||
|
void TestTimelineProjectNode::onEnter()
|
||||||
|
{
|
||||||
|
ActionTimelineTestLayer::onEnter();
|
||||||
|
Node* node = CSLoader::createNode("ActionTimeline/TestAnimation.csb");
|
||||||
|
ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/TestAnimation.csb");
|
||||||
|
|
||||||
|
node->runAction(action);
|
||||||
|
action->gotoFrameAndPlay(0, true);
|
||||||
|
|
||||||
|
node->setPosition(-300, -300);
|
||||||
|
addChild(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string TestTimelineProjectNode::title() const
|
||||||
|
{
|
||||||
|
return "Test ActionTimeline ProjectNode";
|
||||||
|
}
|
||||||
|
|
||||||
|
//TestProjectNodeForSimulator
|
||||||
|
//InnerActionFrame make InnerAction Play until action's duration or next InnerActionFrame
|
||||||
|
void TestProjectNodeForSimulator::onEnter()
|
||||||
|
{
|
||||||
|
ActionTimelineTestLayer::onEnter();
|
||||||
|
Node* node = CSLoader::getInstance()->createNodeWithFlatBuffersForSimulator("ActionTimeline/TestAnimation.csd");
|
||||||
|
ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator("ActionTimeline/TestAnimation.csd");
|
||||||
|
|
||||||
|
node->runAction(action);
|
||||||
|
action->gotoFrameAndPlay(0, true);
|
||||||
|
|
||||||
|
node->setPosition(-300, -300);
|
||||||
|
addChild(node);
|
||||||
|
|
||||||
|
// test for when ProjectNode file lost
|
||||||
|
Node* lackProjectNodefileNode = CSLoader::getInstance()->createNodeWithFlatBuffersForSimulator("ActionTimeline/TestNullProjectNode.csd");
|
||||||
|
ActionTimeline* lackProjectNodefileAction = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator("ActionTimeline/TestNullProjectNode.csd");
|
||||||
|
lackProjectNodefileNode->runAction(lackProjectNodefileAction);
|
||||||
|
lackProjectNodefileAction->gotoFrameAndPlay(0);
|
||||||
|
addChild(lackProjectNodefileNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string TestProjectNodeForSimulator::title() const
|
||||||
|
{
|
||||||
|
return "Test ProjectNode for Simalator";
|
||||||
|
}
|
||||||
|
|
|
@ -25,7 +25,10 @@ enum {
|
||||||
TEST_CHANGE_PLAY_SECTION,
|
TEST_CHANGE_PLAY_SECTION,
|
||||||
// TEST_TIMELINE_FRAME_EVENT,
|
// TEST_TIMELINE_FRAME_EVENT,
|
||||||
TEST_TIMELINE_PERFORMACE,
|
TEST_TIMELINE_PERFORMACE,
|
||||||
|
TEST_TIMELINEACTION_ANIMATIONLIST,
|
||||||
|
TEST_TIMELINEPROJECTNODE,
|
||||||
|
TEST_PROJECTNODEFORSIMALATOR,
|
||||||
|
|
||||||
TEST_ANIMATION_LAYER_COUNT
|
TEST_ANIMATION_LAYER_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,4 +88,25 @@ public:
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TestTimelineAnimationList : public ActionTimelineTestLayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void onEnter();
|
||||||
|
virtual std::string title() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TestTimelineProjectNode : public ActionTimelineTestLayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void onEnter();
|
||||||
|
virtual std::string title() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TestProjectNodeForSimulator : public ActionTimelineTestLayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void onEnter();
|
||||||
|
virtual std::string title() const override;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // __ANIMATION_SCENE_H__
|
#endif // __ANIMATION_SCENE_H__
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,47 @@
|
||||||
|
<GameProjectFile>
|
||||||
|
<PropertyGroup Type="Node" Name="Animation" ID="2a4d9523-ddf0-453e-9409-3dbb8d333900" Version="2.1.0.0" />
|
||||||
|
<Content ctype="GameProjectContent">
|
||||||
|
<Content>
|
||||||
|
<Animation Duration="20" Speed="1.0000">
|
||||||
|
<Timeline ActionTag="-33769691" Property="Position">
|
||||||
|
<PointFrame FrameIndex="0" X="-564.9990" Y="380.0005" />
|
||||||
|
<PointFrame FrameIndex="20" X="57.8571" Y="-0.7137" />
|
||||||
|
</Timeline>
|
||||||
|
<Timeline ActionTag="-33769691" Property="Scale">
|
||||||
|
<ScaleFrame FrameIndex="0" X="1.0000" Y="1.0000" />
|
||||||
|
<ScaleFrame FrameIndex="20" X="1.0000" Y="1.0000" />
|
||||||
|
</Timeline>
|
||||||
|
<Timeline ActionTag="-33769691" Property="RotationSkew">
|
||||||
|
<ScaleFrame FrameIndex="0" X="0.0000" Y="0.0000" />
|
||||||
|
<ScaleFrame FrameIndex="20" X="0.0000" Y="0.0000" />
|
||||||
|
</Timeline>
|
||||||
|
</Animation>
|
||||||
|
<AnimationList>
|
||||||
|
<AnimationInfo Name="Move" StartIndex="0" EndIndex="20">
|
||||||
|
<RenderColor A="150" R="255" G="240" B="245" />
|
||||||
|
</AnimationInfo>
|
||||||
|
</AnimationList>
|
||||||
|
<ObjectData Name="Node" FrameEvent="" Tag="162" ctype="SingleNodeObjectData">
|
||||||
|
<Position X="0.0000" Y="0.0000" />
|
||||||
|
<Scale ScaleX="1.0000" ScaleY="1.0000" />
|
||||||
|
<AnchorPoint />
|
||||||
|
<CColor A="255" R="255" G="255" B="255" />
|
||||||
|
<Size X="0.0000" Y="0.0000" />
|
||||||
|
<PrePosition X="0.0000" Y="0.0000" />
|
||||||
|
<PreSize X="0.0000" Y="0.0000" />
|
||||||
|
<Children>
|
||||||
|
<NodeObjectData Name="Sprite_1" ActionTag="-33769691" FrameEvent="" Tag="163" ObjectIndex="1" LeftMargin="-587.9990" RightMargin="541.9990" TopMargin="-403.0005" BottomMargin="357.0005" ctype="SpriteObjectData">
|
||||||
|
<Position X="-564.9990" Y="380.0005" />
|
||||||
|
<Scale ScaleX="1.0000" ScaleY="1.0000" />
|
||||||
|
<AnchorPoint ScaleX="0.5000" ScaleY="0.5000" />
|
||||||
|
<CColor A="255" R="255" G="255" B="255" />
|
||||||
|
<Size X="46.0000" Y="46.0000" />
|
||||||
|
<PrePosition X="0.0000" Y="0.0000" />
|
||||||
|
<PreSize X="0.0000" Y="0.0000" />
|
||||||
|
<FileData Type="Default" Path="Default/Sprite.png" />
|
||||||
|
</NodeObjectData>
|
||||||
|
</Children>
|
||||||
|
</ObjectData>
|
||||||
|
</Content>
|
||||||
|
</Content>
|
||||||
|
</GameProjectFile>
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
@ -0,0 +1,34 @@
|
||||||
|
<GameProjectFile>
|
||||||
|
<PropertyGroup Type="Scene" Name="TestAnimation" ID="af6d0383-1faa-4b7f-bcf6-d5f4568374b6" Version="2.1.0.0" />
|
||||||
|
<Content ctype="GameProjectContent">
|
||||||
|
<Content>
|
||||||
|
<Animation Duration="30" Speed="1.0000">
|
||||||
|
<Timeline ActionTag="-762514418" Property="ActionValue">
|
||||||
|
<InnerActionFrame FrameIndex="0" InnerActionType="LoopAction" CurrentAniamtionName="Move" SingleFrameIndex="0" />
|
||||||
|
<InnerActionFrame FrameIndex="30" InnerActionType="SingleFrame" CurrentAniamtionName="Move" SingleFrameIndex="0" />
|
||||||
|
</Timeline>
|
||||||
|
</Animation>
|
||||||
|
<ObjectData Name="Scene" FrameEvent="" Tag="164" ctype="SingleNodeObjectData">
|
||||||
|
<Position X="0.0000" Y="0.0000" />
|
||||||
|
<Scale ScaleX="1.0000" ScaleY="1.0000" />
|
||||||
|
<AnchorPoint />
|
||||||
|
<CColor A="255" R="255" G="255" B="255" />
|
||||||
|
<Size X="640.0000" Y="960.0000" />
|
||||||
|
<PrePosition X="0.0000" Y="0.0000" />
|
||||||
|
<PreSize X="0.0000" Y="0.0000" />
|
||||||
|
<Children>
|
||||||
|
<NodeObjectData Name="ProjectNode_1" ActionTag="-762514418" FrameEvent="" Tag="165" ObjectIndex="1" IconVisible="True" LeftMargin="714.5830" RightMargin="-74.5830" TopMargin="642.4999" BottomMargin="317.5002" ctype="ProjectNodeObjectData">
|
||||||
|
<Position X="714.5830" Y="317.5002" />
|
||||||
|
<Scale ScaleX="1.0000" ScaleY="1.0000" />
|
||||||
|
<AnchorPoint />
|
||||||
|
<CColor A="255" R="255" G="255" B="255" />
|
||||||
|
<Size X="0.0000" Y="0.0000" />
|
||||||
|
<PrePosition X="1.1165" Y="0.3307" />
|
||||||
|
<PreSize X="0.0000" Y="0.0000" />
|
||||||
|
<FileData Type="Normal" Path="Animation.csd" />
|
||||||
|
</NodeObjectData>
|
||||||
|
</Children>
|
||||||
|
</ObjectData>
|
||||||
|
</Content>
|
||||||
|
</Content>
|
||||||
|
</GameProjectFile>
|
Binary file not shown.
|
@ -0,0 +1,28 @@
|
||||||
|
<GameProjectFile>
|
||||||
|
<PropertyGroup Type="Scene" Name="TestNullProjectNode" ID="691cf8eb-87a6-4100-b178-07ab0993261f" Version="2.1.0.0" />
|
||||||
|
<Content ctype="GameProjectContent">
|
||||||
|
<Content>
|
||||||
|
<Animation Duration="0" Speed="1.0000" />
|
||||||
|
<ObjectData Name="Scene" FrameEvent="" Tag="114" ctype="SingleNodeObjectData">
|
||||||
|
<Position X="0.0000" Y="0.0000" />
|
||||||
|
<Scale ScaleX="1.0000" ScaleY="1.0000" />
|
||||||
|
<AnchorPoint />
|
||||||
|
<CColor A="255" R="255" G="255" B="255" />
|
||||||
|
<Size X="640.0000" Y="960.0000" />
|
||||||
|
<PrePosition X="0.0000" Y="0.0000" />
|
||||||
|
<PreSize X="0.0000" Y="0.0000" />
|
||||||
|
<Children>
|
||||||
|
<NodeObjectData Name="ProjectNode_1" ActionTag="-181137099" FrameEvent="" Tag="146" ObjectIndex="1" IconVisible="True" ctype="ProjectNodeObjectData">
|
||||||
|
<Position X="131.6666" Y="523.3334" />
|
||||||
|
<Scale ScaleX="1.0000" ScaleY="1.0000" />
|
||||||
|
<AnchorPoint />
|
||||||
|
<CColor A="255" R="255" G="255" B="255" />
|
||||||
|
<Size X="0.0000" Y="0.0000" />
|
||||||
|
<PrePosition X="0.0000" Y="0.0000" />
|
||||||
|
<PreSize X="0.0000" Y="0.0000" />
|
||||||
|
</NodeObjectData>
|
||||||
|
</Children>
|
||||||
|
</ObjectData>
|
||||||
|
</Content>
|
||||||
|
</Content>
|
||||||
|
</GameProjectFile>
|
Binary file not shown.
|
@ -0,0 +1,47 @@
|
||||||
|
<GameProjectFile>
|
||||||
|
<PropertyGroup Type="Node" Name="Animation" ID="2a4d9523-ddf0-453e-9409-3dbb8d333900" Version="2.1.0.0" />
|
||||||
|
<Content ctype="GameProjectContent">
|
||||||
|
<Content>
|
||||||
|
<Animation Duration="20" Speed="1.0000">
|
||||||
|
<Timeline ActionTag="-33769691" Property="Position">
|
||||||
|
<PointFrame FrameIndex="0" X="-564.9990" Y="380.0005" />
|
||||||
|
<PointFrame FrameIndex="20" X="57.8571" Y="-0.7137" />
|
||||||
|
</Timeline>
|
||||||
|
<Timeline ActionTag="-33769691" Property="Scale">
|
||||||
|
<ScaleFrame FrameIndex="0" X="1.0000" Y="1.0000" />
|
||||||
|
<ScaleFrame FrameIndex="20" X="1.0000" Y="1.0000" />
|
||||||
|
</Timeline>
|
||||||
|
<Timeline ActionTag="-33769691" Property="RotationSkew">
|
||||||
|
<ScaleFrame FrameIndex="0" X="0.0000" Y="0.0000" />
|
||||||
|
<ScaleFrame FrameIndex="20" X="0.0000" Y="0.0000" />
|
||||||
|
</Timeline>
|
||||||
|
</Animation>
|
||||||
|
<AnimationList>
|
||||||
|
<AnimationInfo Name="Move" StartIndex="0" EndIndex="20">
|
||||||
|
<RenderColor A="150" R="255" G="240" B="245" />
|
||||||
|
</AnimationInfo>
|
||||||
|
</AnimationList>
|
||||||
|
<ObjectData Name="Node" FrameEvent="" Tag="162" ctype="SingleNodeObjectData">
|
||||||
|
<Position X="0.0000" Y="0.0000" />
|
||||||
|
<Scale ScaleX="1.0000" ScaleY="1.0000" />
|
||||||
|
<AnchorPoint />
|
||||||
|
<CColor A="255" R="255" G="255" B="255" />
|
||||||
|
<Size X="0.0000" Y="0.0000" />
|
||||||
|
<PrePosition X="0.0000" Y="0.0000" />
|
||||||
|
<PreSize X="0.0000" Y="0.0000" />
|
||||||
|
<Children>
|
||||||
|
<NodeObjectData Name="Sprite_1" ActionTag="-33769691" FrameEvent="" Tag="163" ObjectIndex="1" LeftMargin="-587.9990" RightMargin="541.9990" TopMargin="-403.0005" BottomMargin="357.0005" ctype="SpriteObjectData">
|
||||||
|
<Position X="-564.9990" Y="380.0005" />
|
||||||
|
<Scale ScaleX="1.0000" ScaleY="1.0000" />
|
||||||
|
<AnchorPoint ScaleX="0.5000" ScaleY="0.5000" />
|
||||||
|
<CColor A="255" R="255" G="255" B="255" />
|
||||||
|
<Size X="46.0000" Y="46.0000" />
|
||||||
|
<PrePosition X="0.0000" Y="0.0000" />
|
||||||
|
<PreSize X="0.0000" Y="0.0000" />
|
||||||
|
<FileData Type="Default" Path="Default/Sprite.png" />
|
||||||
|
</NodeObjectData>
|
||||||
|
</Children>
|
||||||
|
</ObjectData>
|
||||||
|
</Content>
|
||||||
|
</Content>
|
||||||
|
</GameProjectFile>
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in New Issue