Merge pull request #9585 from doomsdayer/v3_armature_reader

V3 armature reader
This commit is contained in:
minggo 2014-12-24 17:36:09 +08:00
commit 03d53ba7c4
20 changed files with 525 additions and 56 deletions

View File

@ -1253,6 +1253,12 @@
38B8E2E219E671D2002D7CE7 /* UILayoutComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38B8E2DF19E671D2002D7CE7 /* UILayoutComponent.cpp */; };
38B8E2E319E671D2002D7CE7 /* UILayoutComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 38B8E2E019E671D2002D7CE7 /* UILayoutComponent.h */; };
38B8E2E419E671D2002D7CE7 /* UILayoutComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 38B8E2E019E671D2002D7CE7 /* UILayoutComponent.h */; };
38F5263E1A48363B000DB7F7 /* ArmatureNodeReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38F5263B1A48363B000DB7F7 /* ArmatureNodeReader.cpp */; };
38F5263F1A48363B000DB7F7 /* ArmatureNodeReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38F5263B1A48363B000DB7F7 /* ArmatureNodeReader.cpp */; };
38F526401A48363B000DB7F7 /* ArmatureNodeReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 38F5263C1A48363B000DB7F7 /* ArmatureNodeReader.h */; };
38F526411A48363B000DB7F7 /* ArmatureNodeReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 38F5263C1A48363B000DB7F7 /* ArmatureNodeReader.h */; };
38F526421A48363B000DB7F7 /* CSArmatureNode_generated.h in Headers */ = {isa = PBXBuildFile; fileRef = 38F5263D1A48363B000DB7F7 /* CSArmatureNode_generated.h */; };
38F526431A48363B000DB7F7 /* CSArmatureNode_generated.h in Headers */ = {isa = PBXBuildFile; fileRef = 38F5263D1A48363B000DB7F7 /* CSArmatureNode_generated.h */; };
3E2BDADE19C030ED0055CDCD /* AudioEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E2BDADD19C030ED0055CDCD /* AudioEngine.h */; };
3E2BDAEC19C0436F0055CDCD /* AudioEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BDAEB19C0436F0055CDCD /* AudioEngine.cpp */; };
3E2F27A619CFBFE100E7C490 /* AudioEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BDAEB19C0436F0055CDCD /* AudioEngine.cpp */; };
@ -2443,6 +2449,9 @@
38B8E2D419E66581002D7CE7 /* CSLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSLoader.h; sourceTree = "<group>"; };
38B8E2DF19E671D2002D7CE7 /* UILayoutComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutComponent.cpp; sourceTree = "<group>"; };
38B8E2E019E671D2002D7CE7 /* UILayoutComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutComponent.h; sourceTree = "<group>"; };
38F5263B1A48363B000DB7F7 /* ArmatureNodeReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArmatureNodeReader.cpp; sourceTree = "<group>"; };
38F5263C1A48363B000DB7F7 /* ArmatureNodeReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArmatureNodeReader.h; sourceTree = "<group>"; };
38F5263D1A48363B000DB7F7 /* CSArmatureNode_generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSArmatureNode_generated.h; sourceTree = "<group>"; };
3E2BDADD19C030ED0055CDCD /* AudioEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioEngine.h; sourceTree = "<group>"; };
3E2BDAEB19C0436F0055CDCD /* AudioEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioEngine.cpp; sourceTree = "<group>"; };
3E6176551960F89B00DE83F5 /* CCController-iOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "CCController-iOS.mm"; path = "../base/CCController-iOS.mm"; sourceTree = "<group>"; };
@ -4362,6 +4371,16 @@
path = SpriteReader;
sourceTree = "<group>";
};
38F5263A1A48363B000DB7F7 /* ArmatureNodeReader */ = {
isa = PBXGroup;
children = (
38F5263B1A48363B000DB7F7 /* ArmatureNodeReader.cpp */,
38F5263C1A48363B000DB7F7 /* ArmatureNodeReader.h */,
38F5263D1A48363B000DB7F7 /* CSArmatureNode_generated.h */,
);
path = ArmatureNodeReader;
sourceTree = "<group>";
};
46A15FD01807A56F005B8026 /* audio */ = {
isa = PBXGroup;
children = (
@ -4963,6 +4982,7 @@
50FCEB6818C72017004AD434 /* WidgetReader */ = {
isa = PBXGroup;
children = (
38F5263A1A48363B000DB7F7 /* ArmatureNodeReader */,
382384251A2590F9002C4610 /* NodeReader */,
3823843A1A259140002C4610 /* SingleNodeReader */,
382384411A25915C002C4610 /* SpriteReader */,
@ -5209,6 +5229,7 @@
15AE180A19AAD2F700C27E9E /* CCAABB.h in Headers */,
46A170E71807CECA005B8026 /* CCPhysicsBody.h in Headers */,
15AE1A5A19AAD40300C27E9E /* b2StackAllocator.h in Headers */,
38F526401A48363B000DB7F7 /* ArmatureNodeReader.h in Headers */,
B29A7E3119EE1B7700872B35 /* SkinnedMeshAttachment.h in Headers */,
15AE1B6F19AADA9900C27E9E /* GUIDefine.h in Headers */,
15AE1A8119AAD40300C27E9E /* b2FrictionJoint.h in Headers */,
@ -5337,6 +5358,7 @@
15AE1B6C19AADA9900C27E9E /* UIWidget.h in Headers */,
15AE180E19AAD2F700C27E9E /* CCAnimate3D.h in Headers */,
1A5701B3180BCB590088DEC7 /* CCFontFNT.h in Headers */,
38F526421A48363B000DB7F7 /* CSArmatureNode_generated.h in Headers */,
15AE1BD919AAE01E00C27E9E /* CCControlStepper.h in Headers */,
15AE192119AAD35000C27E9E /* CocoStudio.h in Headers */,
15AE18A119AAD33D00C27E9E /* CCNodeLoaderListener.h in Headers */,
@ -5961,6 +5983,7 @@
15AE1AA819AAD40300C27E9E /* b2Island.h in Headers */,
15B3708B19EE414C00ABE682 /* Manifest.h in Headers */,
1A570213180BCBF40088DEC7 /* CCProgressTimer.h in Headers */,
38F526431A48363B000DB7F7 /* CSArmatureNode_generated.h in Headers */,
B37510821823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */,
1A570217180BCBF40088DEC7 /* CCRenderTexture.h in Headers */,
15AE1ABB19AAD40300C27E9E /* b2EdgeAndPolygonContact.h in Headers */,
@ -5992,6 +6015,7 @@
15AE1A3B19AAD3D500C27E9E /* b2BroadPhase.h in Headers */,
15AE195619AAD35100C27E9E /* CCDisplayManager.h in Headers */,
15AE1B8719AADA9A00C27E9E /* UIButton.h in Headers */,
38F526411A48363B000DB7F7 /* ArmatureNodeReader.h in Headers */,
50ABBE441925AB6F00A911A9 /* CCDirector.h in Headers */,
5034CA4A191D591100CE6051 /* ccShader_Label_df.frag in Headers */,
15AE1B7519AADA9A00C27E9E /* UILoadingBar.h in Headers */,
@ -6534,6 +6558,7 @@
382383F01A258FA7002C4610 /* flatc.cpp in Sources */,
1A57028A180BCC900088DEC7 /* CCSpriteFrameCache.cpp in Sources */,
15AE18E619AAD35000C27E9E /* CCActionFrameEasing.cpp in Sources */,
38F5263E1A48363B000DB7F7 /* ArmatureNodeReader.cpp in Sources */,
B29A7DC919EE1B7700872B35 /* SlotData.c in Sources */,
15AE190F19AAD35000C27E9E /* CCInputDelegate.cpp in Sources */,
15AE181A19AAD2F700C27E9E /* CCBundle3D.cpp in Sources */,
@ -7017,6 +7042,7 @@
15AE19B619AAD39700C27E9E /* TextBMFontReader.cpp in Sources */,
15AE1BFD19AAE01E00C27E9E /* CCInvocation.cpp in Sources */,
B24AA98A195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */,
38F5263F1A48363B000DB7F7 /* ArmatureNodeReader.cpp in Sources */,
15AE18CE19AAD33D00C27E9E /* CCNodeLoader.cpp in Sources */,
38ACD1FD1A27111900C3093D /* WidgetCallBackHandlerProtocol.cpp in Sources */,
29394CF719B01DBA00D2DE1A /* UIWebViewImpl-ios.mm in Sources */,

View File

@ -363,6 +363,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="..\editor-support\cocostudio\TriggerMng.cpp" />
<ClCompile Include="..\editor-support\cocostudio\TriggerObj.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetCallBackHandlerProtocol.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\ButtonReader\ButtonReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\CheckBoxReader\CheckBoxReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\ComAudioReader\ComAudioReader.cpp" />
@ -767,6 +768,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\editor-support\cocostudio\TriggerMng.h" />
<ClInclude Include="..\editor-support\cocostudio\TriggerObj.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetCallBackHandlerProtocol.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\CSArmatureNode_generated.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ButtonReader\ButtonReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\CheckBoxReader\CheckBoxReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ComAudioReader\ComAudioReader.h" />

View File

@ -241,6 +241,9 @@
<Filter Include="base\allocator">
<UniqueIdentifier>{92ff4e66-3943-47da-a439-c8f182bb871a}</UniqueIdentifier>
</Filter>
<Filter Include="cocostudio\reader\WidgetReader\ArmatureNodeReader">
<UniqueIdentifier>{e1848cce-b225-42c4-bb6e-6430b6da123b}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\physics\CCPhysicsBody.cpp">
@ -1304,6 +1307,9 @@
<ClCompile Include="..\base\allocator\CCAllocatorGlobalNewDelete.cpp">
<Filter>base\allocator</Filter>
</ClCompile>
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.cpp">
<Filter>cocostudio\reader\WidgetReader\ArmatureNodeReader</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\physics\CCPhysicsBody.h">
@ -2550,6 +2556,12 @@
<ClInclude Include="..\base\allocator\CCAllocatorStrategyPool.h">
<Filter>base\allocator</Filter>
</ClInclude>
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.h">
<Filter>cocostudio\reader\WidgetReader\ArmatureNodeReader</Filter>
</ClInclude>
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\CSArmatureNode_generated.h">
<Filter>cocostudio\reader\WidgetReader\ArmatureNodeReader</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\math\Mat4.inl">

View File

@ -231,6 +231,8 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\TriggerMng.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\TriggerObj.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetCallBackHandlerProtocol.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\CSArmatureNode_generated.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ButtonReader\ButtonReader.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\CheckBoxReader\CheckBoxReader.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ComAudioReader\ComAudioReader.h" />
@ -634,6 +636,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\TriggerMng.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\TriggerObj.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetCallBackHandlerProtocol.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ButtonReader\ButtonReader.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\CheckBoxReader\CheckBoxReader.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ComAudioReader\ComAudioReader.cpp" />

View File

@ -1261,6 +1261,12 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCAsyncTaskPool.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\CSArmatureNode_generated.h">
<Filter>cocostudio\reader\WidgetReader\ArmatureNodeReader</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.h">
<Filter>cocostudio\reader\WidgetReader\ArmatureNodeReader</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\cocos2d.cpp" />
@ -2336,6 +2342,9 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCAsyncTaskPool.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.cpp">
<Filter>cocostudio\reader\WidgetReader\ArmatureNodeReader</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="2d">
@ -2566,6 +2575,9 @@
<Filter Include="cocostudio\reader\WidgetReader\ProjectNodeReader">
<UniqueIdentifier>{a6638f35-5c81-4835-9897-0f9efb0be02b}</UniqueIdentifier>
</Filter>
<Filter Include="cocostudio\reader\WidgetReader\ArmatureNodeReader">
<UniqueIdentifier>{1151b6b3-739f-4cff-add0-6b772fa7d226}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\..\..\cocos2d.def" />

View File

@ -377,6 +377,8 @@
<ClInclude Include="..\editor-support\cocostudio\TriggerMng.h" />
<ClInclude Include="..\editor-support\cocostudio\TriggerObj.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetCallBackHandlerProtocol.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\CSArmatureNode_generated.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ButtonReader\ButtonReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\CheckBoxReader\CheckBoxReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ComAudioReader\ComAudioReader.h" />
@ -853,6 +855,7 @@
<ClCompile Include="..\editor-support\cocostudio\TriggerMng.cpp" />
<ClCompile Include="..\editor-support\cocostudio\TriggerObj.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetCallBackHandlerProtocol.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\ButtonReader\ButtonReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\CheckBoxReader\CheckBoxReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\ComAudioReader\ComAudioReader.cpp" />

View File

@ -242,6 +242,9 @@
<Filter Include="cocostudio\reader\WidgetReader\GameMapReader">
<UniqueIdentifier>{02d389d5-8f57-4bd6-b12a-95af86c5b356}</UniqueIdentifier>
</Filter>
<Filter Include="cocostudio\reader\WidgetReader\ArmatureNodeReader">
<UniqueIdentifier>{939d9d3e-06b3-494e-affd-070c2c1cbe1d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CCAction.cpp">
@ -1311,6 +1314,9 @@
<ClCompile Include="..\base\CCAsyncTaskPool.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.cpp">
<Filter>cocostudio\reader\WidgetReader\ArmatureNodeReader</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CCAction.h">
@ -2544,6 +2550,12 @@
<ClInclude Include="..\base\CCAsyncTaskPool.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\ArmatureNodeReader.h">
<Filter>cocostudio\reader\WidgetReader\ArmatureNodeReader</Filter>
</ClInclude>
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\ArmatureNodeReader\CSArmatureNode_generated.h">
<Filter>cocostudio\reader\WidgetReader\ArmatureNodeReader</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\math\Mat4.inl">

View File

@ -57,6 +57,7 @@
#include "cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.h"
#include "cocostudio/WidgetReader/PageViewReader/PageViewReader.h"
#include "cocostudio/WidgetReader/ListViewReader/ListViewReader.h"
#include "cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.h"
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/util.h"
@ -200,6 +201,8 @@ CSLoader::CSLoader()
CREATE_CLASS_NODE_READER_INFO(PageViewReader);
CREATE_CLASS_NODE_READER_INFO(ListViewReader);
CREATE_CLASS_NODE_READER_INFO(ArmatureNodeReader);
}
void CSLoader::purge()
@ -789,12 +792,23 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree)
{
node = createNodeWithFlatBuffersFile(filePath);
reader->setPropsWithFlatBuffers(node, options->data());
bool isloop = projectNodeOptions->isLoop();
bool isautoplay = projectNodeOptions->isAutoPlay();
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
if(action)
if (action)
{
node->runAction(action);
action->gotoFrameAndPlay(0);
if (isautoplay)
{
action->gotoFrameAndPlay(0, isloop);
}
else
{
action->gotoFrameAndPause(0);
}
}
}
}
@ -1125,12 +1139,22 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
{
node = createNodeWithFlatBuffersForSimulator(filePath);
reader->setPropsWithFlatBuffers(node, options->data());
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath);
bool isloop = projectNodeOptions->isLoop();
bool isautoplay = projectNodeOptions->isAutoPlay();
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
if (action)
{
node->runAction(action);
action->gotoFrameAndPlay(0);
if (isautoplay)
{
action->gotoFrameAndPlay(0, isloop);
}
else
{
action->gotoFrameAndPause(0);
}
}
}
}

View File

@ -68,8 +68,8 @@ ActionTimeline/CCTimeLine.cpp \
ActionTimeline/CCActionTimeline.cpp \
ActionTimeline/CSLoader.cpp \
FlatBuffersSerialize.cpp \
WidgetCallBackHandlerProtocol.cpp
WidgetCallBackHandlerProtocol.cpp \
WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/..

View File

@ -69,6 +69,7 @@ set(COCOS_CS_SRC
editor-support/cocostudio/ActionTimeline/CCTimeLine.cpp
editor-support/cocostudio/ActionTimeline/CSLoader.cpp
editor-support/cocostudio/FlatBuffersSerialize.cpp
editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp
)
include_directories( editor-support )

View File

@ -1187,9 +1187,29 @@ Offset<ProjectNodeOptions> FlatBuffersSerialize::createProjectNodeOptionsForSimu
{
auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, _builder);
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
std::string filename = "";
bool isloop = true;
bool isAutoPlay = true;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "IsLoop")
{
isloop = (value == "True") ? true : false;
}
else if (attriname == "IsAutoPlay")
{
isAutoPlay = (value == "True") ? true : false;
}
attribute = attribute->Next();
}
// FileData
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
while (child)
@ -1219,7 +1239,9 @@ Offset<ProjectNodeOptions> FlatBuffersSerialize::createProjectNodeOptionsForSimu
return CreateProjectNodeOptions(*_builder,
nodeOptions,
_builder->CreateString(filename));
_builder->CreateString(filename),
isloop,
isAutoPlay);
}
}

View File

@ -0,0 +1,160 @@
#include "tinyxml2/tinyxml2.h"
#include "flatbuffers/flatbuffers.h"
#include "cocostudio/WidgetReader/NodeReader/NodeReader.h"
#include "cocostudio/CSParseBinary_generated.h"
#include "CSArmatureNode_generated.h"
#include "cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.h"
#include "cocostudio/CCArmature.h"
USING_NS_CC;
using namespace cocostudio;
using namespace flatbuffers;
IMPLEMENT_CLASS_NODE_READER_INFO(ArmatureNodeReader)
ArmatureNodeReader::ArmatureNodeReader()
{
}
ArmatureNodeReader::~ArmatureNodeReader()
{
}
static ArmatureNodeReader* _instanceArmatureNodeReader = nullptr;
ArmatureNodeReader* ArmatureNodeReader::getInstance()
{
if (_instanceArmatureNodeReader == nullptr)
{
_instanceArmatureNodeReader = new (std::nothrow) ArmatureNodeReader();
}
return _instanceArmatureNodeReader;
}
Offset<Table> ArmatureNodeReader::createOptionsWithFlatBuffers(const tinyxml2::XMLElement *objectData,
flatbuffers::FlatBufferBuilder *builder)
{
auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
bool isloop = false;
bool isAutoPlay = false;
std::string currentAnimationName = "";
int type = 0;
std::string path = "";
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "IsLoop")
{
isloop = (value == "True") ? true : false;
}
else if (attriname == "IsAutoPlay")
{
isAutoPlay = (value == "True") ? true : false;
}
else if (attriname == "CurrentAnimationName")
{
currentAnimationName = value;
}
attribute = attribute->Next();
}
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
while (child)
{
std::string attriname = child->Name();
if (attriname == "FileData")
{
attribute = child->FirstAttribute();
while (attribute)
{
attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "Type")
{
type = 0;
}
else if (attriname == "Path")
{
path = value;
}
attribute = attribute->Next();
}
}
child = child->NextSiblingElement();
}
auto options = CreateCSArmatureNodeOption(*builder,
nodeOptions,
CreateResourceItemData(*builder,
type,
builder->CreateString(path)),
isloop,
isAutoPlay,
builder->CreateString(currentAnimationName));
return *(Offset<Table>*)(&options);
}
void ArmatureNodeReader::setPropsWithFlatBuffers(cocos2d::Node *node,
const flatbuffers::Table *nodeOptions)
{
auto* custom = static_cast<CCArmature*>(node);
auto options = (flatbuffers::CSArmatureNodeOption*)nodeOptions;
auto reader = ArmatureNodeReader::getInstance();
std::string filepath(options->fileData()->path()->c_str());
ArmatureDataManager::getInstance()->addArmatureFileInfo(FileUtils::getInstance()->fullPathForFilename(filepath));
custom->init(getArmatureName(filepath));
if (options->isAutoPlay())
custom->getAnimation()->play(options->currentAnimationName()->c_str(), -1, options->isLoop());
else
custom->getAnimation()->setIsPlaying(false);
}
cocos2d::Node* ArmatureNodeReader::createNodeWithFlatBuffers(const flatbuffers::Table *nodeOptions)
{
auto node = CCArmature::create();
// self
auto options = (flatbuffers::CSArmatureNodeOption*)nodeOptions;
setPropsWithFlatBuffers(node, (Table*)options);
// super node
auto NodeReader = NodeReader::getInstance();
NodeReader->setPropsWithFlatBuffers(node, (Table*)options->nodeOptions());
return node;
}
std::string ArmatureNodeReader::getArmatureName(const std::string& exporJsonPath)
{
//FileUtils.getFileData(exporJsonPath, "r", size) // need read armature name in exportJsonPath
int end = exporJsonPath.find_last_of(".");
int start = exporJsonPath.find_last_of("\\") + 1;
int start1 = exporJsonPath.find_last_of("/") + 1;
if (start < start1)
start = start1;
if (start == -1)
start = 0;
return exporJsonPath.substr(start, end - start);
}

View File

@ -0,0 +1,65 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __ARMATURENODEREADER_H_
#define __ARMATURENODEREADER_H_
#include "cocos2d.h"
#include "cocostudio/FlatBuffersSerialize.h"
#include "cocostudio/WidgetReader/NodeReaderProtocol.h"
#include "cocostudio/WidgetReader/NodeReaderDefine.h"
/****************************************
* reader of CSArmatureNode
* @param register reader before use it:
CSLoader* instance = CSLoader::getInstance();
instance->registReaderObject("ArmatureNodeReader", (ObjectFactory::Instance)CustomSpriteReader::getInstance);
*@param Reader's name must be CLASSNAME#Reader, CLASSNAME is the dataobject's prefix: CLASSNAME#ObjectData
*
*
*****************************************/
class ArmatureNodeReader : public cocos2d::Ref, public cocostudio::NodeReaderProtocol
{
DECLARE_CLASS_NODE_READER_INFO
public:
ArmatureNodeReader();
~ArmatureNodeReader();
static ArmatureNodeReader* getInstance();
static void purge();
flatbuffers::Offset<flatbuffers::Table> createOptionsWithFlatBuffers(const tinyxml2::XMLElement* objectData,
flatbuffers::FlatBufferBuilder* builder);
void setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* textBMFontOptions);
//CSArmatureNode
cocos2d::Node* createNodeWithFlatBuffers(const flatbuffers::Table* nodeOptions) override;
private:
std::string getArmatureName(const std::string& exporJsonPath);
};
#endif /* defined(__ARMATURENODEREADER_H_) */

View File

@ -0,0 +1,108 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_CSARMATURENODE_FLATBUFFERS_H_
#define FLATBUFFERS_GENERATED_CSARMATURENODE_FLATBUFFERS_H_
#include "flatbuffers/flatbuffers.h"
namespace flatbuffers {
struct CSArmatureNodeOption;
struct ResourceItemData;
struct CSArmatureNodeOption : private flatbuffers::Table {
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
const ResourceItemData *fileData() const { return GetPointer<const ResourceItemData *>(6); }
uint8_t isLoop() const { return GetField<uint8_t>(8, 1); }
uint8_t isAutoPlay() const { return GetField<uint8_t>(10, 1); }
const flatbuffers::String *currentAnimationName() const { return GetPointer<const flatbuffers::String *>(12); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
verifier.VerifyTable(nodeOptions()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileData */) &&
verifier.VerifyTable(fileData()) &&
VerifyField<uint8_t>(verifier, 8 /* isLoop */) &&
VerifyField<uint8_t>(verifier, 10 /* isAutoPlay */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* currentAnimationName */) &&
verifier.Verify(currentAnimationName()) &&
verifier.EndTable();
}
};
struct CSArmatureNodeOptionBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
void add_fileData(flatbuffers::Offset<ResourceItemData> fileData) { fbb_.AddOffset(6, fileData); }
void add_isLoop(uint8_t isLoop) { fbb_.AddElement<uint8_t>(8, isLoop, 1); }
void add_isAutoPlay(uint8_t isAutoPlay) { fbb_.AddElement<uint8_t>(10, isAutoPlay, 1); }
void add_currentAnimationName(flatbuffers::Offset<flatbuffers::String> currentAnimationName) { fbb_.AddOffset(12, currentAnimationName); }
CSArmatureNodeOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
CSArmatureNodeOptionBuilder &operator=(const CSArmatureNodeOptionBuilder &);
flatbuffers::Offset<CSArmatureNodeOption> Finish() {
auto o = flatbuffers::Offset<CSArmatureNodeOption>(fbb_.EndTable(start_, 5));
return o;
}
};
inline flatbuffers::Offset<CSArmatureNodeOption> CreateCSArmatureNodeOption(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
flatbuffers::Offset<ResourceItemData> fileData = 0,
uint8_t isLoop = 1,
uint8_t isAutoPlay = 1,
flatbuffers::Offset<flatbuffers::String> currentAnimationName = 0) {
CSArmatureNodeOptionBuilder builder_(_fbb);
builder_.add_currentAnimationName(currentAnimationName);
builder_.add_fileData(fileData);
builder_.add_nodeOptions(nodeOptions);
builder_.add_isAutoPlay(isAutoPlay);
builder_.add_isLoop(isLoop);
return builder_.Finish();
}
struct ResourceItemData : private flatbuffers::Table {
int32_t type() const { return GetField<int32_t>(4, 0); }
const flatbuffers::String *path() const { return GetPointer<const flatbuffers::String *>(6); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<int32_t>(verifier, 4 /* type */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* path */) &&
verifier.Verify(path()) &&
verifier.EndTable();
}
};
struct ResourceItemDataBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_type(int32_t type) { fbb_.AddElement<int32_t>(4, type, 0); }
void add_path(flatbuffers::Offset<flatbuffers::String> path) { fbb_.AddOffset(6, path); }
ResourceItemDataBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
ResourceItemDataBuilder &operator=(const ResourceItemDataBuilder &);
flatbuffers::Offset<ResourceItemData> Finish() {
auto o = flatbuffers::Offset<ResourceItemData>(fbb_.EndTable(start_, 2));
return o;
}
};
inline flatbuffers::Offset<ResourceItemData> CreateResourceItemData(flatbuffers::FlatBufferBuilder &_fbb,
int32_t type = 0,
flatbuffers::Offset<flatbuffers::String> path = 0) {
ResourceItemDataBuilder builder_(_fbb);
builder_.add_path(path);
builder_.add_type(type);
return builder_.Finish();
}
inline const CSArmatureNodeOption *GetCSArmatureNodeOption(const void *buf) { return flatbuffers::GetRoot<CSArmatureNodeOption>(buf); }
inline bool VerifyCSArmatureNodeOptionBuffer(flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<CSArmatureNodeOption>(); }
inline void FinishCSArmatureNodeOptionBuffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<CSArmatureNodeOption> root) { fbb.Finish(root); }
} // namespace flatbuffers
#endif // FLATBUFFERS_GENERATED_CSARMATURENODE_FLATBUFFERS_H_

View File

@ -69,7 +69,27 @@ namespace cocostudio
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
std::string filename = "";
bool isloop = true;
bool isAutoPlay = true;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "IsLoop")
{
isloop = (value == "True") ? true : false;
}
else if (attriname == "IsAutoPlay")
{
isAutoPlay = (value == "True") ? true : false;
}
attribute = attribute->Next();
}
// FileData
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
while (child)
@ -101,49 +121,9 @@ namespace cocostudio
auto options = CreateProjectNodeOptions(*builder,
nodeOptions,
builder->CreateString(filename));
return *(Offset<Table>*)(&options);
}
Offset<Table> ProjectNodeReader::createOptionsWithFlatBuffersForSimulator(const tinyxml2::XMLElement *objectData,
flatbuffers::FlatBufferBuilder *builder)
{
auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
std::string filename = "";
// FileData
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
while (child)
{
std::string name = child->Name();
if (name == "FileData")
{
const tinyxml2::XMLAttribute* attribute = child->FirstAttribute();
while (attribute)
{
name = attribute->Name();
std::string value = attribute->Value();
if (name == "Path")
{
filename = value;
}
attribute = attribute->Next();
}
}
child = child->NextSiblingElement();
}
auto options = CreateProjectNodeOptions(*builder,
nodeOptions,
builder->CreateString(filename));
builder->CreateString(filename),
isloop,
isAutoPlay);
return *(Offset<Table>*)(&options);
}

View File

@ -44,8 +44,7 @@ namespace cocostudio
flatbuffers::Offset<flatbuffers::Table> createOptionsWithFlatBuffers(const tinyxml2::XMLElement* objectData,
flatbuffers::FlatBufferBuilder* builder);
flatbuffers::Offset<flatbuffers::Table> createOptionsWithFlatBuffersForSimulator(const tinyxml2::XMLElement* objectData,
flatbuffers::FlatBufferBuilder* builder);
void setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* projectNodeOptions);
cocos2d::Node* createNodeWithFlatBuffers(const flatbuffers::Table* nodeOptions) { return nullptr; };
};

View File

@ -123,6 +123,7 @@ bool AppDelegate::applicationDidFinishLaunching()
searchPaths.push_back("ccs-res/hd/cocosui/CustomTest/CustomWidgetCallbackBindTest");
searchPaths.push_back("hd/ActionTimeline");
searchPaths.push_back("ccs-res/hd/armature");
}
else
{
@ -163,6 +164,8 @@ bool AppDelegate::applicationDidFinishLaunching()
searchPaths.push_back("ccs-res/cocosui/CustomTest/CustomWidgetCallbackBindTest");
searchPaths.push_back("ActionTimeline");
searchPaths.push_back("ccs-res/armature");
}
fileUtils->setSearchPaths(searchPaths);

View File

@ -78,6 +78,9 @@ Layer *CreateLayer(int index)
case TEST_DIRECT_FROM_BINARY:
pLayer = new (std::nothrow) TestLoadFromBinary();
break;
case TEST_ARMATURE_NODE:
pLayer = new (std::nothrow) TestArmatureNode();
break;
default:
break;
}
@ -1601,3 +1604,27 @@ void TestLoadFromBinary::dataLoaded( float percent )
m_armatureIndex = 0;
}
}
//TestArmatureNode
void TestArmatureNode::onEnter()
{
ArmatureTestLayer::onEnter();
auto node = CSLoader::createNode("TestArmatureNode.csb");
addChild(node);
node->setPositionX(Director::getInstance()->getVisibleSize().width * .25f);
}
std::string TestArmatureNode::title() const
{
return "Test Armature Node";
}
std::string TestArmatureNode::subtitle() const
{
return "Csb file loaded";
}

View File

@ -46,6 +46,7 @@ enum {
TEST_EASING,
TEST_CHANGE_ANIMATION_INTERNAL,
TEST_DIRECT_FROM_BINARY,
TEST_ARMATURE_NODE,
TEST_LAYER_COUNT
};
@ -412,4 +413,12 @@ private:
int m_armatureIndex; // index of sync loaded armature, default -1 is none
};
class TestArmatureNode : public ArmatureTestLayer
{
public:
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
#endif // __HELLOWORLD_SCENE_H__

@ -1 +1 @@
Subproject commit 84e5fd6000d7439082f6a8b507f520a52c50ad4e
Subproject commit 3a3364d79fe4c8fa6487b65edf7a2104a496903e