This commit is contained in:
yangxiao 2014-06-20 18:54:34 +08:00
commit 1581396810
194 changed files with 7562 additions and 330 deletions

View File

@ -752,6 +752,8 @@ Developers:
hanjukim
Fixed a bug that color and opacity settings were not applied when invoking Label::alignText.
Fixed the bug that FileUtils:getStringFromFile() may return a unterminated string
Skip BOM in DataReaderHelper::addDataFromJsonCache()
bagobor
Fixed a memory leak in AssetsManager::uncompress.
@ -893,6 +895,9 @@ Developers:
Fix the bug that UIButton doesn't support TTF font
Fix a but of TextReader
gin0606
Add a new line at the end of a file
Retired Core Developers:
WenSheng Yang
Author of windows port, CCTextField,

View File

@ -1,6 +1,8 @@
cocos2d-x-3.2 ???
[NEW] Node: added getName(), setName(), getChildByName(), enumerateChildren()
[NEW] Label: support setting line height and additional kerning of label that not using system font
[FIX] FileUtils: getStringFromFile may return a unterminated string
[FIX] UIButton: doesn't support TTF font
cocos2d-x-3.2-alpha0 Jun.17 2014

View File

@ -100,6 +100,8 @@ endif()
if(MINGW)
add_definitions(-DGLEW_STATIC)
add_definitions(-D__SSIZE_T)
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lws2_32")
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lws2_32")
endif()

View File

@ -40,6 +40,28 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
0634A4D0194B19E400E608AF /* CCActionTimeline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C5194B19E400E608AF /* CCActionTimeline.cpp */; };
0634A4D1194B19E400E608AF /* CCActionTimeline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C5194B19E400E608AF /* CCActionTimeline.cpp */; };
0634A4D2194B19E400E608AF /* CCActionTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4C6194B19E400E608AF /* CCActionTimeline.h */; };
0634A4D3194B19E400E608AF /* CCActionTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4C6194B19E400E608AF /* CCActionTimeline.h */; };
0634A4D4194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C7194B19E400E608AF /* CCActionTimelineCache.cpp */; };
0634A4D5194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C7194B19E400E608AF /* CCActionTimelineCache.cpp */; };
0634A4D6194B19E400E608AF /* CCActionTimelineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4C8194B19E400E608AF /* CCActionTimelineCache.h */; };
0634A4D7194B19E400E608AF /* CCActionTimelineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4C8194B19E400E608AF /* CCActionTimelineCache.h */; };
0634A4D8194B19E400E608AF /* CCFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C9194B19E400E608AF /* CCFrame.cpp */; };
0634A4D9194B19E400E608AF /* CCFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C9194B19E400E608AF /* CCFrame.cpp */; };
0634A4DA194B19E400E608AF /* CCFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CA194B19E400E608AF /* CCFrame.h */; };
0634A4DB194B19E400E608AF /* CCFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CA194B19E400E608AF /* CCFrame.h */; };
0634A4DC194B19E400E608AF /* CCNodeReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4CB194B19E400E608AF /* CCNodeReader.cpp */; };
0634A4DD194B19E400E608AF /* CCNodeReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4CB194B19E400E608AF /* CCNodeReader.cpp */; };
0634A4DE194B19E400E608AF /* CCNodeReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CC194B19E400E608AF /* CCNodeReader.h */; };
0634A4DF194B19E400E608AF /* CCNodeReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CC194B19E400E608AF /* CCNodeReader.h */; };
0634A4E0194B19E400E608AF /* CCTimeLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4CD194B19E400E608AF /* CCTimeLine.cpp */; };
0634A4E1194B19E400E608AF /* CCTimeLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4CD194B19E400E608AF /* CCTimeLine.cpp */; };
0634A4E2194B19E400E608AF /* CCTimeLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CE194B19E400E608AF /* CCTimeLine.h */; };
0634A4E3194B19E400E608AF /* CCTimeLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CE194B19E400E608AF /* CCTimeLine.h */; };
0634A4E4194B19E400E608AF /* CCTimelineMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CF194B19E400E608AF /* CCTimelineMacro.h */; };
0634A4E5194B19E400E608AF /* CCTimelineMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CF194B19E400E608AF /* CCTimelineMacro.h */; };
06CAAAC5186AD7E50012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; };
06CAAAC6186AD7E60012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; };
06CAAAC7186AD7E90012A414 /* TriggerObj.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAAC0186AD63B0012A414 /* TriggerObj.cpp */; };
@ -1887,6 +1909,17 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0634A4C5194B19E400E608AF /* CCActionTimeline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionTimeline.cpp; sourceTree = "<group>"; };
0634A4C6194B19E400E608AF /* CCActionTimeline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTimeline.h; sourceTree = "<group>"; };
0634A4C7194B19E400E608AF /* CCActionTimelineCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionTimelineCache.cpp; sourceTree = "<group>"; };
0634A4C8194B19E400E608AF /* CCActionTimelineCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTimelineCache.h; sourceTree = "<group>"; };
0634A4C9194B19E400E608AF /* CCFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFrame.cpp; sourceTree = "<group>"; };
0634A4CA194B19E400E608AF /* CCFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFrame.h; sourceTree = "<group>"; };
0634A4CB194B19E400E608AF /* CCNodeReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeReader.cpp; sourceTree = "<group>"; };
0634A4CC194B19E400E608AF /* CCNodeReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeReader.h; sourceTree = "<group>"; };
0634A4CD194B19E400E608AF /* CCTimeLine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTimeLine.cpp; sourceTree = "<group>"; };
0634A4CE194B19E400E608AF /* CCTimeLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTimeLine.h; sourceTree = "<group>"; };
0634A4CF194B19E400E608AF /* CCTimelineMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTimelineMacro.h; sourceTree = "<group>"; };
06CAAABC186AD63B0012A414 /* TriggerBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerBase.cpp; sourceTree = "<group>"; };
06CAAABD186AD63B0012A414 /* TriggerBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriggerBase.h; sourceTree = "<group>"; };
06CAAABE186AD63B0012A414 /* TriggerMng.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerMng.cpp; sourceTree = "<group>"; };
@ -2934,6 +2967,24 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0634A4C4194B19E400E608AF /* ActionTimeline */ = {
isa = PBXGroup;
children = (
0634A4C5194B19E400E608AF /* CCActionTimeline.cpp */,
0634A4C6194B19E400E608AF /* CCActionTimeline.h */,
0634A4C7194B19E400E608AF /* CCActionTimelineCache.cpp */,
0634A4C8194B19E400E608AF /* CCActionTimelineCache.h */,
0634A4C9194B19E400E608AF /* CCFrame.cpp */,
0634A4CA194B19E400E608AF /* CCFrame.h */,
0634A4CB194B19E400E608AF /* CCNodeReader.cpp */,
0634A4CC194B19E400E608AF /* CCNodeReader.h */,
0634A4CD194B19E400E608AF /* CCTimeLine.cpp */,
0634A4CE194B19E400E608AF /* CCTimeLine.h */,
0634A4CF194B19E400E608AF /* CCTimelineMacro.h */,
);
path = ActionTimeline;
sourceTree = "<group>";
};
1551A334158F2AB200E66CFE = {
isa = PBXGroup;
children = (
@ -3590,6 +3641,7 @@
1A8C5946180E930E00EF57C3 /* cocostudio */ = {
isa = PBXGroup;
children = (
0634A4C4194B19E400E608AF /* ActionTimeline */,
50FCEB6818C72017004AD434 /* WidgetReader */,
06CAAAC1186AD63B0012A414 /* TriggerObj.h */,
06CAAABC186AD63B0012A414 /* TriggerBase.cpp */,
@ -4916,6 +4968,7 @@
50ABBE731925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */,
1A570063180BC5A10088DEC7 /* CCAction.h in Headers */,
1A570067180BC5A10088DEC7 /* CCActionCamera.h in Headers */,
0634A4DA194B19E400E608AF /* CCFrame.h in Headers */,
1A57006B180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */,
1A57006F180BC5A10088DEC7 /* CCActionEase.h in Headers */,
1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */,
@ -5020,6 +5073,7 @@
1A570294180BCCAB0088DEC7 /* CCAnimation.h in Headers */,
50ABBD421925AB0000A911A9 /* CCMathBase.h in Headers */,
1A570298180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */,
0634A4DE194B19E400E608AF /* CCNodeReader.h in Headers */,
50FCEB9D18C72017004AD434 /* ImageViewReader.h in Headers */,
B29594C81926D61F003EEF37 /* CCObjLoader.h in Headers */,
50ABBE911925AB6F00A911A9 /* CCPlatformMacros.h in Headers */,
@ -5080,6 +5134,7 @@
1AD71DCF180E26E600808F54 /* CCControlLoader.h in Headers */,
50ABBE7B1925AB6F00A911A9 /* CCEventMouse.h in Headers */,
1AD71DD3180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */,
0634A4D6194B19E400E608AF /* CCActionTimelineCache.h in Headers */,
1AD71DD7180E26E600808F54 /* CCLabelTTFLoader.h in Headers */,
1AD71DDB180E26E600808F54 /* CCLayerColorLoader.h in Headers */,
503DD8F91926B0DB00CD74DD /* CCIMEDispatcher.h in Headers */,
@ -5148,6 +5203,7 @@
50ABBE3F1925AB6F00A911A9 /* CCDataVisitor.h in Headers */,
1AD71EDF180E26E600808F54 /* Slot.h in Headers */,
1AD71EE3180E26E600808F54 /* SlotData.h in Headers */,
0634A4E2194B19E400E608AF /* CCTimeLine.h in Headers */,
1AD71EE7180E26E600808F54 /* spine-cocos2dx.h in Headers */,
1AD71EE9180E26E600808F54 /* spine.h in Headers */,
1AAF536C180E3374000584C8 /* HttpClient.h in Headers */,
@ -5179,6 +5235,7 @@
50ABBE371925AB6F00A911A9 /* CCConsole.h in Headers */,
1A8C59A1180E930E00EF57C3 /* CCArmature.h in Headers */,
1A8C59A5180E930E00EF57C3 /* CCArmatureAnimation.h in Headers */,
0634A4D2194B19E400E608AF /* CCActionTimeline.h in Headers */,
1A8C59A9180E930E00EF57C3 /* CCArmatureDataManager.h in Headers */,
50ABC00B1926664800A911A9 /* CCDevice.h in Headers */,
2905FA7A18CF08D100240AA3 /* UISlider.h in Headers */,
@ -5217,6 +5274,7 @@
50ABBD951925AB4100A911A9 /* CCGLProgramState.h in Headers */,
1A8C59F1180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */,
1A8C59F5180E930E00EF57C3 /* CCSSceneReader.h in Headers */,
0634A4E4194B19E400E608AF /* CCTimelineMacro.h in Headers */,
1A8C59F9180E930E00EF57C3 /* CCTransformHelp.h in Headers */,
1A8C59FD180E930E00EF57C3 /* CCTween.h in Headers */,
1A8C5A05180E930E00EF57C3 /* CCUtilMath.h in Headers */,
@ -5380,6 +5438,7 @@
2AC795EA1862875D005EC8E1 /* BoundingBoxAttachment.h in Headers */,
503DD8F01926736A00CD74DD /* CCStdC.h in Headers */,
46A170FF1807CECB005B8026 /* CCPhysicsContact.h in Headers */,
0634A4D3194B19E400E608AF /* CCActionTimeline.h in Headers */,
50ABBDA21925AB4100A911A9 /* CCGroupCommand.h in Headers */,
503DD8EF1926736A00CD74DD /* CCPlatformDefine.h in Headers */,
46A171041807CECB005B8026 /* CCPhysicsShape.h in Headers */,
@ -5392,6 +5451,7 @@
46A170FD1807CECB005B8026 /* CCPhysicsBody.h in Headers */,
2905FA6118CF08D100240AA3 /* UILayoutParameter.h in Headers */,
B29594C51926D61F003EEF37 /* CCMesh.h in Headers */,
0634A4DB194B19E400E608AF /* CCFrame.h in Headers */,
50ABBE9C1925AB6F00A911A9 /* CCRef.h in Headers */,
50ABBD961925AB4100A911A9 /* CCGLProgramState.h in Headers */,
46A171061807CECB005B8026 /* CCPhysicsWorld.h in Headers */,
@ -5403,6 +5463,7 @@
50ABBEC21925AB6F00A911A9 /* CCValue.h in Headers */,
2905FA5518CF08D100240AA3 /* UIImageView.h in Headers */,
50ABBECA1925AB6F00A911A9 /* firePngData.h in Headers */,
0634A4E3194B19E400E608AF /* CCTimeLine.h in Headers */,
50ABBE401925AB6F00A911A9 /* CCDataVisitor.h in Headers */,
1A570064180BC5A10088DEC7 /* CCAction.h in Headers */,
06CAAACE186AD7FA0012A414 /* TriggerBase.h in Headers */,
@ -5460,6 +5521,7 @@
1A57011E180BC90D0088DEC7 /* CCGrabber.h in Headers */,
1A570122180BC90D0088DEC7 /* CCGrid.h in Headers */,
50FCEBBA18C72017004AD434 /* TextAtlasReader.h in Headers */,
0634A4D7194B19E400E608AF /* CCActionTimelineCache.h in Headers */,
5034CA2E191D591100CE6051 /* ccShader_PositionTextureA8Color.frag in Headers */,
50ABBD5B1925AB0000A911A9 /* Vec2.h in Headers */,
50ABBD411925AB0000A911A9 /* CCMath.h in Headers */,
@ -5543,6 +5605,7 @@
50ABBE2A1925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */,
1A57030F180BCF190088DEC7 /* CCComponent.h in Headers */,
1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */,
0634A4DF194B19E400E608AF /* CCNodeReader.h in Headers */,
1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */,
2905FA6518CF08D100240AA3 /* UIListView.h in Headers */,
50FCEBAA18C72017004AD434 /* LoadingBarReader.h in Headers */,
@ -5664,6 +5727,7 @@
1A9DCA2A180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */,
1A01C69F18F57BE800EFE3A6 /* CCString.h in Headers */,
1A01C69118F57BE800EFE3A6 /* CCDictionary.h in Headers */,
0634A4E5194B19E400E608AF /* CCTimelineMacro.h in Headers */,
1A8C598E180E930E00EF57C3 /* CCActionFrame.h in Headers */,
1A8C5992180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */,
5034CA36191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */,
@ -6100,6 +6164,7 @@
1A01C6A418F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */,
46A170EA1807CECA005B8026 /* CCPhysicsJoint.cpp in Sources */,
5027253C190BF1B900AAF4ED /* cocos2d.cpp in Sources */,
0634A4D4194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */,
50ABC0611926664800A911A9 /* CCCommon.mm in Sources */,
50ABBDB11925AB4100A911A9 /* ccShaders.cpp in Sources */,
46A170EF1807CECA005B8026 /* CCPhysicsWorld.cpp in Sources */,
@ -6218,6 +6283,7 @@
1A5702EE180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */,
50ABBE691925AB6F00A911A9 /* CCEventListenerFocus.cpp in Sources */,
1A5702F2180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */,
0634A4DC194B19E400E608AF /* CCNodeReader.cpp in Sources */,
1A5702F6180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */,
1A5702FA180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */,
50ABBD5C1925AB0000A911A9 /* Vec3.cpp in Sources */,
@ -6306,6 +6372,7 @@
1AD71EE5180E26E600808F54 /* spine-cocos2dx.cpp in Sources */,
1AAF536A180E3374000584C8 /* HttpClient.cpp in Sources */,
50ABC0631926664800A911A9 /* CCDevice.mm in Sources */,
0634A4E0194B19E400E608AF /* CCTimeLine.cpp in Sources */,
1AAF5372180E3374000584C8 /* SocketIO.cpp in Sources */,
50ABBE1F1925AB6F00A911A9 /* atitc.cpp in Sources */,
1AAF5376180E3374000584C8 /* WebSocket.cpp in Sources */,
@ -6348,6 +6415,7 @@
2905FA7C18CF08D100240AA3 /* UIText.cpp in Sources */,
50FCEB9F18C72017004AD434 /* LayoutReader.cpp in Sources */,
50ABC0211926664800A911A9 /* CCGLView.cpp in Sources */,
0634A4D8194B19E400E608AF /* CCFrame.cpp in Sources */,
1A8C59C7180E930E00EF57C3 /* CCComRender.cpp in Sources */,
50ABC00D1926664800A911A9 /* CCFileUtils.cpp in Sources */,
1A8C59CB180E930E00EF57C3 /* CCDataReaderHelper.cpp in Sources */,
@ -6362,6 +6430,7 @@
1A8C59D7180E930E00EF57C3 /* CCDisplayFactory.cpp in Sources */,
50ABBD601925AB0000A911A9 /* Vec4.cpp in Sources */,
1A8C59DB180E930E00EF57C3 /* CCDisplayManager.cpp in Sources */,
0634A4D0194B19E400E608AF /* CCActionTimeline.cpp in Sources */,
2905FA6218CF08D100240AA3 /* UIListView.cpp in Sources */,
1A8C59DF180E930E00EF57C3 /* CCInputDelegate.cpp in Sources */,
1A8C59E3180E930E00EF57C3 /* CCProcessBase.cpp in Sources */,
@ -6556,6 +6625,7 @@
3EA0FB6C191C841D00B170C8 /* UIVideoPlayerIOS.mm in Sources */,
1A570062180BC5A10088DEC7 /* CCAction.cpp in Sources */,
1A570066180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */,
0634A4D9194B19E400E608AF /* CCFrame.cpp in Sources */,
1A57006A180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */,
1A57006E180BC5A10088DEC7 /* CCActionEase.cpp in Sources */,
50ABBD8C1925AB4100A911A9 /* CCGLProgram.cpp in Sources */,
@ -6564,6 +6634,7 @@
B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */,
2905FA8D18CF08D100240AA3 /* UIWidget.cpp in Sources */,
B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */,
0634A4D5194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */,
50ABBE7E1925AB6F00A911A9 /* CCEventTouch.cpp in Sources */,
50FCEB9818C72017004AD434 /* CheckBoxReader.cpp in Sources */,
50ABBE6E1925AB6F00A911A9 /* CCEventListenerKeyboard.cpp in Sources */,
@ -6623,6 +6694,7 @@
50ABBD9C1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */,
1A5701E7180BCB8C0088DEC7 /* CCTransition.cpp in Sources */,
50ABC01E1926664800A911A9 /* CCThread.cpp in Sources */,
0634A4D1194B19E400E608AF /* CCActionTimeline.cpp in Sources */,
1A5701EB180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp in Sources */,
1A5701EF180BCB8C0088DEC7 /* CCTransitionProgress.cpp in Sources */,
1A5701F8180BCBAD0088DEC7 /* CCMenu.cpp in Sources */,
@ -6680,6 +6752,7 @@
50ABBDB61925AB4100A911A9 /* CCTexture2D.cpp in Sources */,
1A570355180BD0B00088DEC7 /* ioapi.cpp in Sources */,
1A570359180BD0B00088DEC7 /* unzip.cpp in Sources */,
0634A4E1194B19E400E608AF /* CCTimeLine.cpp in Sources */,
1AD71DAA180E26E600808F54 /* CCBAnimationManager.cpp in Sources */,
50ABBD881925AB4100A911A9 /* CCCustomCommand.cpp in Sources */,
50ABBE941925AB6F00A911A9 /* CCProfiling.cpp in Sources */,
@ -6826,6 +6899,7 @@
2905FA7518CF08D100240AA3 /* UIScrollView.cpp in Sources */,
1A8C5A0E180E930E00EF57C3 /* DictionaryHelper.cpp in Sources */,
1ABA68AF1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */,
0634A4DD194B19E400E608AF /* CCNodeReader.cpp in Sources */,
50ABBE7A1925AB6F00A911A9 /* CCEventMouse.cpp in Sources */,
50ABBD981925AB4100A911A9 /* CCGLProgramStateCache.cpp in Sources */,
B6B26344193884D60088FE25 /* CCAnimation3D.cpp in Sources */,

View File

@ -804,6 +804,10 @@
29080DE4191B595E0066F8DF /* UIWidgetAddNodeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29080D89191B595E0066F8DF /* UIWidgetAddNodeTest.cpp */; };
29080DE5191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29080D8B191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp */; };
29080DE6191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29080D8B191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp */; };
38FA2E73194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */; };
38FA2E74194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */; };
38FA2E76194AECF800FF2BE4 /* ActionTimeline in Resources */ = {isa = PBXBuildFile; fileRef = 38FA2E75194AECF800FF2BE4 /* ActionTimeline */; };
38FA2E77194AECF800FF2BE4 /* ActionTimeline in Resources */ = {isa = PBXBuildFile; fileRef = 38FA2E75194AECF800FF2BE4 /* ActionTimeline */; };
3E92EA821921A1400094CD21 /* Sprite3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E92EA801921A1400094CD21 /* Sprite3DTest.cpp */; };
3E92EA831921A1400094CD21 /* Sprite3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E92EA801921A1400094CD21 /* Sprite3DTest.cpp */; };
3E92EA851921A7720094CD21 /* Sprite3DTest in Resources */ = {isa = PBXBuildFile; fileRef = 3E92EA841921A7720094CD21 /* Sprite3DTest */; };
@ -1840,6 +1844,9 @@
29080D8A191B595E0066F8DF /* UIWidgetAddNodeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidgetAddNodeTest.h; sourceTree = "<group>"; };
29080D8B191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIWidgetAddNodeTest_Editor.cpp; sourceTree = "<group>"; };
29080D8C191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidgetAddNodeTest_Editor.h; sourceTree = "<group>"; };
38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActionTimelineTestScene.cpp; sourceTree = "<group>"; };
38FA2E72194AEBE100FF2BE4 /* ActionTimelineTestScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionTimelineTestScene.h; sourceTree = "<group>"; };
38FA2E75194AECF800FF2BE4 /* ActionTimeline */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ActionTimeline; path = "../tests/cpp-tests/Resources/ActionTimeline"; sourceTree = "<group>"; };
3E92EA801921A1400094CD21 /* Sprite3DTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sprite3DTest.cpp; path = Sprite3DTest/Sprite3DTest.cpp; sourceTree = "<group>"; };
3E92EA811921A1400094CD21 /* Sprite3DTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sprite3DTest.h; path = Sprite3DTest/Sprite3DTest.h; sourceTree = "<group>"; };
3E92EA841921A7720094CD21 /* Sprite3DTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Sprite3DTest; path = "../tests/cpp-tests/Resources/Sprite3DTest"; sourceTree = "<group>"; };
@ -2541,6 +2548,7 @@
1AC359B418CECF0B00F37B72 /* ExtensionsTest */ = {
isa = PBXGroup;
children = (
38FA2E70194AEBE100FF2BE4 /* CocoStudioActionTimelineTest */,
1AC359B518CECF0B00F37B72 /* CocosBuilderTest */,
1AC359DC18CECF0B00F37B72 /* CocoStudioArmatureTest */,
1AC359DF18CECF0B00F37B72 /* CocoStudioComponentsTest */,
@ -3240,6 +3248,7 @@
1AC35CA818CED83500F37B72 /* Resources */ = {
isa = PBXGroup;
children = (
38FA2E75194AECF800FF2BE4 /* ActionTimeline */,
B2507B6A192589AF00FA4972 /* Shaders3D */,
3E92EA841921A7720094CD21 /* Sprite3DTest */,
3EA0FB5D191B92F100B170C8 /* cocosvideo.mp4 */,
@ -3757,6 +3766,15 @@
name = Frameworks;
sourceTree = "<group>";
};
38FA2E70194AEBE100FF2BE4 /* CocoStudioActionTimelineTest */ = {
isa = PBXGroup;
children = (
38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */,
38FA2E72194AEBE100FF2BE4 /* ActionTimelineTestScene.h */,
);
path = CocoStudioActionTimelineTest;
sourceTree = "<group>";
};
3E92EA7D1921A0C60094CD21 /* Sprite3DTest */ = {
isa = PBXGroup;
children = (
@ -4383,6 +4401,7 @@
1AC35CE018CED84500F37B72 /* configs in Resources */,
1AC35CE618CED84500F37B72 /* effect2.ogg in Resources */,
1AC35CFA18CED84500F37B72 /* Misc in Resources */,
38FA2E76194AECF800FF2BE4 /* ActionTimeline in Resources */,
1AC35D0418CED84500F37B72 /* Shaders in Resources */,
1AC35CD818CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */,
B2507B6B192589AF00FA4972 /* Shaders3D in Resources */,
@ -4451,6 +4470,7 @@
1AC35CF318CED84500F37B72 /* Hello.png in Resources */,
1AC35C8F18CECF1400F37B72 /* Icon-152.png in Resources */,
1AC35CE718CED84500F37B72 /* effect2.ogg in Resources */,
38FA2E77194AECF800FF2BE4 /* ActionTimeline in Resources */,
1AC35C9718CECF1400F37B72 /* Icon-80.png in Resources */,
1AC35CEB18CED84500F37B72 /* fileLookup.plist in Resources */,
1AC35CFD18CED84500F37B72 /* music.mid in Resources */,
@ -4686,6 +4706,7 @@
1AC35C2B18CECF0C00F37B72 /* PerformanceLabelTest.cpp in Sources */,
1AC35C0118CECF0C00F37B72 /* TableViewTestScene.cpp in Sources */,
1AC35C4B18CECF0C00F37B72 /* ShaderTest2.cpp in Sources */,
38FA2E73194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */,
1AC35C6518CECF0C00F37B72 /* UnitTest.cpp in Sources */,
29080DC9191B595E0066F8DF /* UISceneManager_Editor.cpp in Sources */,
1AC35B3F18CECF0C00F37B72 /* Bug-458.cpp in Sources */,
@ -4729,6 +4750,7 @@
29080D8E191B595E0066F8DF /* CocosGUIScene.cpp in Sources */,
1AC35BFA18CECF0C00F37B72 /* WebSocketTest.cpp in Sources */,
1AC35BF218CECF0C00F37B72 /* EditBoxTest.cpp in Sources */,
38FA2E74194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */,
1AC35B3A18CECF0C00F37B72 /* Bug-1174.cpp in Sources */,
1AC35BE418CECF0C00F37B72 /* CCControlColourPickerTest.cpp in Sources */,
29080DD4191B595E0066F8DF /* UITextAtlasTest.cpp in Sources */,

View File

@ -240,6 +240,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
TextVAlignment vAlignment /* = TextVAlignment::TOP */,bool useDistanceField /* = false */,bool useA8Shader /* = false */)
: _reusedLetter(nullptr)
, _commonLineHeight(0.0f)
, _additionalKerning(0.0f)
, _lineBreakWithoutSpaces(false)
, _maxLineWidth(0)
, _labelWidth(0)
@ -719,8 +720,16 @@ void Label::sortAllChildren()
void Label::enableGlow(const Color4B& glowColor)
{
if(! _useDistanceField)
return;
if (_currentLabelType == LabelType::TTF)
{
if (_fontConfig.distanceFieldEnabled == false)
{
auto config = _fontConfig;
config.outlineSize = 0;
config.distanceFieldEnabled = true;
setTTFConfig(config);
_contentDirty = true;
}
_currLabelEffect = LabelEffect::GLOW;
_effectColor = glowColor;
_effectColorF.r = _effectColor.r / 255.0f;
@ -728,10 +737,13 @@ void Label::enableGlow(const Color4B& glowColor)
_effectColorF.b = _effectColor.b / 255.0f;
_effectColorF.a = _effectColor.a / 255.0f;
updateShaderProgram();
}
}
void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */)
{
CCASSERT(_currentLabelType == LabelType::STRING_TEXTURE || _currentLabelType == LabelType::TTF, "Only supported system font and TTF!");
_effectColor = outlineColor;
_effectColorF.r = _effectColor.r / 255.0f;
_effectColorF.g = _effectColor.g / 255.0f;
@ -1098,7 +1110,9 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
setOrderOfArrival(0);
// FIX ME: Why need to set _orderOfArrival to 0??
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
// setOrderOfArrival(0);
}
void Label::setSystemFontName(const std::string& systemFont)
@ -1163,9 +1177,38 @@ Sprite * Label::getLetter(int letterIndex)
return nullptr;
}
int Label::getCommonLineHeight() const
void Label::setLineHeight(float height)
{
return _textSprite ? 0 : _commonLineHeight;
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
if (_commonLineHeight != height)
{
_commonLineHeight = height;
_contentDirty = true;
}
}
float Label::getLineHeight() const
{
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
return _textSprite ? 0.0f : _commonLineHeight;
}
void Label::setAdditionalKerning(float space)
{
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
if (_additionalKerning != space)
{
_additionalKerning = space;
_contentDirty = true;
}
}
float Label::getAdditionalKerning() const
{
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
return _additionalKerning;
}
void Label::computeStringNumLines()
@ -1247,6 +1290,8 @@ void Label::updateDisplayedOpacity(GLubyte parentOpacity)
void Label::setTextColor(const Color4B &color)
{
CCASSERT(_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::STRING_TEXTURE, "Only supported system font and ttf!");
_textColor = color;
_textColorF.r = _textColor.r / 255.0f;
_textColorF.g = _textColor.g / 255.0f;

View File

@ -91,6 +91,7 @@ public:
/** Creates a label with an initial string,font file,font size, dimension in points, horizontal alignment and vertical alignment.
* @warning Not support font name.
* @warning Cache textures for each different font size or font file.
*/
static Label * createWithTTF(const std::string& text, const std::string& fontFile, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
@ -98,6 +99,8 @@ public:
/** Create a label with TTF configuration
* @warning Not support font name.
* @warning Cache textures for each different font file when enable distance field.
* @warning Cache textures for each different font size or font file when disable distance field.
*/
static Label* createWithTTF(const TTFConfig& ttfConfig, const std::string& text, TextHAlignment alignment = TextHAlignment::LEFT, int maxLineWidth = 0);
@ -136,6 +139,17 @@ public:
virtual const std::string& getString() const override { return _originalUTF8String; }
/** Sets the text color of the label
* Only support for TTF and system font
* @warning Different from the color of Node.
*/
virtual void setTextColor(const Color4B &color);
/** Returns the text color of this label
* Only support for TTF and system font
* @warning Different from the color of Node.
*/
const Color4B& getTextColor() const { return _textColor;}
/**
* Enable shadow for the label
*
@ -193,21 +207,33 @@ public:
/** update content immediately.*/
virtual void updateContent();
/** Sets the text color
*
*/
virtual void setTextColor(const Color4B &color);
const Color4B& getTextColor() const { return _textColor;}
virtual Sprite * getLetter(int lettetIndex);
/** clip upper and lower margin for reduce height of label.
*/
void setClipMarginEnabled(bool clipEnabled) { _clipEnabled = clipEnabled; }
bool isClipMarginEnabled() const { return _clipEnabled; }
// font related stuff
int getCommonLineHeight() const;
/** Sets the line height of the label
@warning Not support system font
@since v3.2.0
*/
void setLineHeight(float height);
/** Returns the line height of this label
@warning Not support system font
*/
float getLineHeight() const;
/** Sets the additional kerning of the label
@warning Not support system font
@since v3.2.0
*/
void setAdditionalKerning(float space);
/** Returns the additional kerning of this label
@warning Not support system font
@since v3.2.0
*/
float getAdditionalKerning() const;
// string related stuff
int getStringNumLines() const { return _currNumLines;}
@ -247,6 +273,8 @@ public:
CC_DEPRECATED_ATTRIBUTE virtual void setFontDefinition(const FontDefinition& textDefinition);
CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; }
CC_DEPRECATED_ATTRIBUTE int getCommonLineHeight() const { return getLineHeight();}
protected:
void onDraw(const Mat4& transform, bool transformUpdated);
@ -331,6 +359,7 @@ protected:
Rect _reusedRect;
int _limitShowCount;
float _additionalKerning;
float _commonLineHeight;
bool _lineBreakWithoutSpaces;
int * _horizontalKernings;

View File

@ -384,7 +384,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
continue;
}
nextFontPositionX += charAdvance + kernings[i];
nextFontPositionX += charAdvance + kernings[i] + theLabel->_additionalKerning;
if (longestLine < nextFontPositionX)
{

View File

@ -1210,6 +1210,11 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t paren
}
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
// FIX ME: Why need to set _orderOfArrival to 0??
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
// reset for next frame
// _orderOfArrival = 0;
}
Mat4 Node::transform(const Mat4& parentTransform)

View File

@ -162,7 +162,9 @@ void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uin
draw(renderer, _modelViewTransform, flags);
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
setOrderOfArrival(0);
// FIX ME: Why need to set _orderOfArrival to 0??
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
// setOrderOfArrival(0);
CC_PROFILER_STOP_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
}

View File

@ -178,6 +178,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClCompile Include="..\3d\CCAnimate3D.cpp" />
<ClCompile Include="..\3d\CCAnimation3D.cpp" />
<ClCompile Include="..\3d\CCBundle3D.cpp" />
<ClCompile Include="..\3d\CCBundleReader.cpp" />
<ClCompile Include="..\3d\CCMesh.cpp" />
<ClCompile Include="..\3d\CCMeshSkin.cpp" />
<ClCompile Include="..\3d\CCObjLoader.cpp" />
@ -356,6 +357,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClInclude Include="..\3d\CCAnimationCurve.h" />
<ClInclude Include="..\3d\CCBundle3D.h" />
<ClInclude Include="..\3d\CCBundle3DData.h" />
<ClInclude Include="..\3d\CCBundleReader.h" />
<ClInclude Include="..\3d\CCMesh.h" />
<ClInclude Include="..\3d\CCMeshSkin.h" />
<ClInclude Include="..\3d\CCObjLoader.h" />

View File

@ -580,6 +580,9 @@
<ClCompile Include="..\3d\CCSprite3DMaterial.cpp">
<Filter>3d</Filter>
</ClCompile>
<ClCompile Include="..\3d\CCBundleReader.cpp">
<Filter>3d</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\physics\CCPhysicsBody.h">
@ -1180,6 +1183,9 @@
<ClInclude Include="..\3d\CCSprite3DMaterial.h">
<Filter>3d</Filter>
</ClInclude>
<ClInclude Include="..\3d\CCBundleReader.h">
<Filter>3d</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\math\Mat4.inl">

View File

@ -27,7 +27,22 @@
#include "base/ccMacros.h"
#include "platform/CCFileUtils.h"
#include "renderer/CCGLProgram.h"
#include "CCBundleReader.h"
#include "base/CCData.h"
#define BUNDLE_TYPE_SCENE 1
#define BUNDLE_TYPE_NODE 2
#define BUNDLE_TYPE_ANIMATIONS 3
#define BUNDLE_TYPE_ANIMATION 4
#define BUNDLE_TYPE_ANIMATION_CHANNEL 5
#define BUNDLE_TYPE_MODEL 10
#define BUNDLE_TYPE_MATERIAL 16
#define BUNDLE_TYPE_EFFECT 18
#define BUNDLE_TYPE_CAMERA 32
#define BUNDLE_TYPE_LIGHT 33
#define BUNDLE_TYPE_MESH 34
#define BUNDLE_TYPE_MESHPART 35
#define BUNDLE_TYPE_MESHSKIN 36
NS_CC_BEGIN
@ -58,27 +73,6 @@ void getChildMap(std::map<int, std::vector<int> >& map, SkinData* skinData, cons
}
}
void getChildMapT(std::map<std::string, std::vector<std::string> >& map, const SkinData* skinData, const rapidjson::Value& val)
{
if (!skinData)
return;
if (!val.HasMember("children"))
return;
std::string parent_name = val["id"].GetString();
const rapidjson::Value& children = val["children"];
for (rapidjson::SizeType i = 0; i < children.Size(); i++)
{
const rapidjson::Value& child = children[i];
std::string child_name = child["id"].GetString();
map[parent_name].push_back(child_name);
getChildMapT(map, skinData, child);
}
}
Bundle3D* Bundle3D::_instance = nullptr;
Bundle3D* Bundle3D::getInstance()
@ -93,30 +87,108 @@ void Bundle3D::destroyInstance()
CC_SAFE_DELETE(_instance);
}
void Bundle3D::clearBuffer()
{
CC_SAFE_DELETE_ARRAY(_jsonBuffer);
CC_SAFE_DELETE(_binaryBuffer);
}
bool Bundle3D::load(const std::string& path)
{
if (_path == path)
return true;
getModelPath(path);
std::string strFileString = FileUtils::getInstance()->getStringFromFile(path);
ssize_t size = strFileString.length();
CC_SAFE_DELETE_ARRAY(_documentBuffer);
_documentBuffer = new char[size + 1];
memcpy(_documentBuffer, strFileString.c_str(), size);
_documentBuffer[size] = '\0';
if (_document.ParseInsitu<0>(_documentBuffer).HasParseError())
getModelRelativePath(path);
bool ret = false;
std::string ext = path.substr(path.length() - 4, 4);
std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
if (ext == ".c3t")
{
assert(0);
CC_SAFE_DELETE_ARRAY(_documentBuffer);
_path = "";
return false;
_isBinary = false;
ret = loadJson(path);
}
_path = path;
return true;
else if (ext == ".c3b")
{
_isBinary = true;
ret = loadBinary(path);
}
else
{
CCLOGINFO("%s is invalid file formate", path);
}
ret?(_path = path):(_path = "");
return ret;
}
bool Bundle3D::loadMeshData(const std::string& id, MeshData* meshdata)
{
if (_isBinary)
{
return loadMeshDataBinary(meshdata);
}
else
{
return loadMeshDataJson(meshdata);
}
}
bool Bundle3D::loadSkinData(const std::string& id, SkinData* skindata)
{
if (_isBinary)
{
return loadSkinDataBinary(skindata);
}
else
{
return loadSkinDataJson(skindata);
}
}
bool Bundle3D::loadMaterialData(const std::string& id, MaterialData* materialdata)
{
if (_isBinary)
{
return loadMaterialDataBinary(materialdata);
}
else
{
return loadMaterialDataJson(materialdata);
}
}
bool Bundle3D::loadAnimationData(const std::string& id, Animation3DData* animationdata)
{
if (_isBinary)
{
return loadAnimationDataBinary(animationdata);
}
else
{
return loadAnimationDataJson(animationdata);
}
}
bool Bundle3D::loadJson(const std::string& path)
{
std::string strFileString = FileUtils::getInstance()->getStringFromFile(path);
ssize_t size = strFileString.length();
CC_SAFE_DELETE_ARRAY(_jsonBuffer);
_jsonBuffer = new char[size + 1];
memcpy(_jsonBuffer, strFileString.c_str(), size);
_jsonBuffer[size] = '\0';
if (_document.ParseInsitu<0>(_jsonBuffer).HasParseError())
{
assert(0);
CC_SAFE_DELETE_ARRAY(_jsonBuffer);
return false;
}
return true;
}
bool Bundle3D::loadMeshDataJson(MeshData* meshdata)
{
meshdata->resetData();
@ -160,7 +232,7 @@ bool Bundle3D::loadMeshData(const std::string& id, MeshData* meshdata)
const rapidjson::Value& mesh_vertex_attribute_val = mesh_vertex_attribute[i];
meshdata->attribs[i].size = mesh_vertex_attribute_val["size"].GetUint();
meshdata->attribs[i].attribSizeBytes = meshdata->attribs[i].size * parseGLTypeSize(mesh_vertex_attribute_val["type"].GetString());
meshdata->attribs[i].attribSizeBytes = meshdata->attribs[i].size * 4;
meshdata->attribs[i].type = parseGLType(mesh_vertex_attribute_val["type"].GetString());
meshdata->attribs[i].vertexAttrib = parseGLProgramAttribute(mesh_vertex_attribute_val["attribute"].GetString());
}
@ -168,7 +240,7 @@ bool Bundle3D::loadMeshData(const std::string& id, MeshData* meshdata)
return true;
}
bool Bundle3D::loadSkinData(const std::string& id, SkinData* skindata)
bool Bundle3D::loadSkinDataJson(SkinData* skindata)
{
if (!_document.HasMember("skin")) return false;
@ -205,7 +277,7 @@ bool Bundle3D::loadSkinData(const std::string& id, SkinData* skindata)
return true;
}
bool Bundle3D::loadMaterialData(const std::string& id, MaterialData* materialdata)
bool Bundle3D::loadMaterialDataJson(MaterialData* materialdata)
{
if (!_document.HasMember("material"))
return false;
@ -223,7 +295,7 @@ bool Bundle3D::loadMaterialData(const std::string& id, MaterialData* materialdat
return true;
}
bool Bundle3D::loadAnimationData(const std::string& id, Animation3DData* animationdata)
bool Bundle3D::loadAnimationDataJson(Animation3DData* animationdata)
{
if (!_document.HasMember("animation")) return false;
@ -282,6 +354,290 @@ bool Bundle3D::loadAnimationData(const std::string& id, Animation3DData* animati
return true;
}
bool Bundle3D::loadBinary(const std::string& path)
{
// get file data
CC_SAFE_DELETE(_binaryBuffer);
_binaryBuffer = new Data();
*_binaryBuffer = FileUtils::getInstance()->getDataFromFile(path);
if (_binaryBuffer->isNull())
{
CCLOGINFO(false, "Failed to read file: %s", path.c_str());
return false;
}
// Create bundle reader
CC_SAFE_DELETE(_bundleReader);
_bundleReader = BundleReader::create((char*)_binaryBuffer->getBytes(), _binaryBuffer->getSize());
// Read identifier info
char identifier[] = { 'C', '3', 'B', '\0'};
char sig[4];
if (_bundleReader->read(sig, 1, 4) != 4 || memcmp(sig, identifier, 4) != 0)
{
CCLOGINFO(false, "Invalid identifier: %s", path.c_str());
return false;
}
// Read version
unsigned char ver[2];
if (_bundleReader->read(ver, 1, 2) != 2 || ver[0] != 0 || ver[1] != 1)
{
CCLOGINFO(false, "Unsupported version: (%d, %d)", ver[0], ver[1]);
return false;
}
// Read ref table size
if (_bundleReader->read(&_referenceCount, 4, 1) != 1)
{
CCLOGINFO("Failed to read ref table size '%s'.", path.c_str());
return false;
}
// Read all refs
CC_SAFE_DELETE_ARRAY(_references);
_references = new Reference[_referenceCount];
for (unsigned int i = 0; i < _referenceCount; ++i)
{
if ((_references[i].id = _bundleReader->readString()).empty() ||
_bundleReader->read(&_references[i].type, 4, 1) != 1 ||
_bundleReader->read(&_references[i].offset, 4, 1) != 1)
{
CCLOGINFO("Failed to read ref number %d for bundle '%s'.", i, path.c_str());
CC_SAFE_DELETE_ARRAY(_references);
return false;
}
}
return true;
}
bool Bundle3D::loadMeshDataBinary(MeshData* meshdata)
{
if (!seekToFirstType(BUNDLE_TYPE_MESH))
return false;
meshdata->resetData();
// read mesh data
if (_bundleReader->read(&meshdata->attribCount, 4, 1) != 1 || meshdata->attribCount < 1)
{
CCLOGINFO("Failed to read meshdata: attribCount '%s'.", _path.c_str());
return false;
}
meshdata->attribs.resize(meshdata->attribCount);
for (ssize_t i = 0; i < meshdata->attribCount; i++)
{
unsigned int vUsage, vSize;
if (_bundleReader->read(&vUsage, 4, 1) != 1 || _bundleReader->read(&vSize, 4, 1) != 1)
{
CCLOGINFO("Failed to read meshdata: usage or size '%s'.", _path.c_str());
return false;
}
meshdata->attribs[i].size = vSize;
meshdata->attribs[i].attribSizeBytes = meshdata->attribs[i].size * 4;
meshdata->attribs[i].type = GL_FLOAT;
meshdata->attribs[i].vertexAttrib = vUsage;
}
// Read vertex data
if (_bundleReader->read(&meshdata->vertexSizeInFloat, 4, 1) != 1 || meshdata->vertexSizeInFloat == 0)
{
CCLOGINFO("Failed to read meshdata: vertexSizeInFloat '%s'.", _path.c_str());
return false;
}
meshdata->vertex.resize(meshdata->vertexSizeInFloat);
if (_bundleReader->read(&meshdata->vertex[0], 4, meshdata->vertexSizeInFloat) != meshdata->vertexSizeInFloat)
{
CCLOGINFO("Failed to read meshdata: vertex element '%s'.", _path.c_str());
return false;
}
// Read index data
unsigned int meshPartCount = 1;
//_bundleReader->read(&meshPartCount, 4, 1);
for (unsigned int i = 0; i < meshPartCount; ++i)
{
unsigned int nIndexCount;
if (_bundleReader->read(&nIndexCount, 4, 1) != 1)
{
CCLOGINFO("Failed to read meshdata: nIndexCount '%s'.", _path.c_str());
return false;
}
meshdata->numIndex = nIndexCount;
meshdata->indices.resize(meshdata->numIndex);
if (_bundleReader->read(&meshdata->indices[0], 2, meshdata->numIndex) != nIndexCount)
{
CCLOGINFO("Failed to read meshdata: indices '%s'.", _path.c_str());
return false;
}
}
return true;
}
bool Bundle3D::loadSkinDataBinary(SkinData* skindata)
{
if (!seekToFirstType(BUNDLE_TYPE_MESHSKIN))
return false;
skindata->resetData();
// transform
float bindShape[16];
if (!_bundleReader->readMatrix(bindShape))
{
CCLOGINFO("Failed to read SkinData: bindShape matrix '%s'.", _path.c_str());
return false;
}
// bone count
unsigned int boneNum;
if (!_bundleReader->read(&boneNum))
{
CCLOGINFO("Failed to read SkinData: boneNum '%s'.", _path.c_str());
return false;
}
// bone names and bind pos
float bindpos[16];
for (unsigned int i = 0; i < boneNum; i++)
{
skindata->boneNames.push_back(_bundleReader->readString());
if (!_bundleReader->readMatrix(bindpos))
{
CCLOGINFO("Failed to load SkinData: bindpos '%s'.", _path.c_str());
return NULL;
}
skindata->inverseBindPoseMatrices.push_back(bindpos);
}
// bind shape
bindShape[16];
_bundleReader->readMatrix(bindShape);
// read parent and child relationship map
float transform[16];
unsigned int linkNum;
_bundleReader->read(&linkNum);
for (unsigned int i = 0; i < linkNum; ++i)
{
std::string id = _bundleReader->readString();
int index = skindata->getBoneNameIndex(id);
if (index >= 0 && skindata->rootBoneIndex < 0)
skindata->rootBoneIndex = index;
std::string parentid = _bundleReader->readString();
int parentIndex = skindata->getBoneNameIndex(parentid);
if (!_bundleReader->readMatrix(transform))
{
CCLOGINFO("Failed to load SkinData: transform '%s'.", _path.c_str());
return NULL;
}
if (parentIndex < 0 || index < 0)
continue;
skindata->boneChild[parentIndex].push_back(index);
}
return true;
}
bool Bundle3D::loadMaterialDataBinary(MaterialData* materialdata)
{
if (!seekToFirstType(BUNDLE_TYPE_MATERIAL))
return false;
std::string texturePath = _bundleReader->readString();
if (texturePath.empty())
{
CCLOGINFO("Failed to read Materialdata: texturePath is empty '%s'.", _path.c_str());
return false;
}
materialdata->texturePath = _modelRelativePath + texturePath;
return true;
}
bool Bundle3D::loadAnimationDataBinary(Animation3DData* animationdata)
{
if (!seekToFirstType(BUNDLE_TYPE_ANIMATIONS))
return false;
animationdata->_rotationKeys.clear();
animationdata->_scaleKeys.clear();
animationdata->_translationKeys.clear();
std::string id = _bundleReader->readString();
if (!_bundleReader->read(&animationdata->_totalTime))
{
CCLOGINFO("Failed to read AnimationData: totalTime '%s'.", _path.c_str());
return false;
}
unsigned int animNum;
if (!_bundleReader->read(&animNum))
{
CCLOGINFO("Failed to read AnimationData: animNum '%s'.", _path.c_str());
return false;
}
for (unsigned int i = 0; i < animNum; ++i)
{
std::string boneName = _bundleReader->readString();
unsigned int keyframeNum;
if (!_bundleReader->read(&keyframeNum))
{
CCLOGINFO("Failed to read AnimationData: keyframeNum '%s'.", _path.c_str());
return false;
}
for (unsigned int j = 0; j < keyframeNum; ++j)
{
float keytime;
if (!_bundleReader->read(&keytime))
{
CCLOGINFO("Failed to read AnimationData: keytime '%s'.", _path.c_str());
return false;
}
Quaternion rotate;
if (_bundleReader->read(&rotate, 4, 4) != 4)
{
CCLOGINFO("Failed to read AnimationData: rotate '%s'.", _path.c_str());
return false;
}
animationdata->_rotationKeys[boneName].push_back(Animation3DData::QuatKey(keytime, rotate));
Vec3 scale;
if (_bundleReader->read(&scale, 4, 3) != 3)
{
CCLOGINFO("Failed to read AnimationData: scale '%s'.", _path.c_str());
return false;
}
animationdata->_scaleKeys[boneName].push_back(Animation3DData::Vec3Key(keytime, scale));
Vec3 position;
if (_bundleReader->read(&position, 4, 3) != 3)
{
CCLOGINFO("Failed to read AnimationData: position '%s'.", _path.c_str());
return false;
}
animationdata->_translationKeys[boneName].push_back(Animation3DData::Vec3Key(keytime, position));
}
}
return true;
}
GLenum Bundle3D::parseGLType(const std::string& str)
{
if (str == "GL_FLOAT")
@ -299,23 +655,6 @@ GLenum Bundle3D::parseGLType(const std::string& str)
}
}
unsigned int Bundle3D::parseGLTypeSize(const std::string& str)
{
if (str == "GL_FLOAT")
{
return sizeof(float);
}
else if (str == "GL_UNSIGNED_INT")
{
return sizeof(unsigned int);
}
else
{
assert(0);
return -1;
}
}
unsigned int Bundle3D::parseGLProgramAttribute(const std::string& str)
{
if (str == "VERTEX_ATTRIB_POSITION")
@ -349,7 +688,7 @@ unsigned int Bundle3D::parseGLProgramAttribute(const std::string& str)
}
}
void Bundle3D::getModelPath(const std::string& path)
void Bundle3D::getModelRelativePath(const std::string& path)
{
int index = path.find_last_of('/');
std::string fullModelPath;
@ -366,19 +705,44 @@ void Bundle3D::getModelPath(const std::string& path)
}
}
Reference* Bundle3D::seekToFirstType(unsigned int type)
{
// for each Reference
for (unsigned int i = 0; i < _referenceCount; ++i)
{
Reference* ref = &_references[i];
if (ref->type == type)
{
// Found a match
if (_bundleReader->seek(ref->offset, SEEK_SET) == false)
{
CCLOGINFO("Failed to seek to object '%s' in bundle '%s'.", ref->id.c_str(), _path.c_str());
return NULL;
}
return ref;
}
}
return NULL;
}
Bundle3D::Bundle3D()
:_isBinary(false)
,_modelRelativePath("")
,_documentBuffer(nullptr)
,_path("")
:_isBinary(false),
_modelRelativePath(""),
_jsonBuffer(NULL),
_path(""),
_referenceCount(0),
_bundleReader(NULL),
_references(NULL),
_binaryBuffer(NULL)
{
}
Bundle3D::~Bundle3D()
{
CC_SAFE_DELETE_ARRAY(_documentBuffer);
CC_SAFE_DELETE_ARRAY(_jsonBuffer);
CC_SAFE_DELETE_ARRAY(_bundleReader);
CC_SAFE_DELETE_ARRAY(_references);
CC_SAFE_DELETE(_binaryBuffer);
}
NS_CC_END

View File

@ -36,6 +36,9 @@
#include "json/document.h"
NS_CC_BEGIN
class BundleReader;
class Animation3D;
class Data;
/**
* Defines a bundle file that contains a collection of assets. Mesh, Material, MeshSkin, Animation
@ -51,6 +54,8 @@ public:
static void destroyInstance();
void clearBuffer();
/**
* load a file. You must load a file first, then call loadMeshData, loadSkinData, and so on
* @param path File to be loaded
@ -83,15 +88,73 @@ public:
bool loadAnimationData(const std::string& id, Animation3DData* animationdata);
protected:
bool loadJson(const std::string& path);
bool loadMeshDataJson(MeshData* meshdata);
bool loadSkinDataJson(SkinData* skindata);
bool loadMaterialDataJson(MaterialData* materialdata);
bool loadAnimationDataJson(Animation3DData* animationdata);
/**
* load data in binary
* @param path The c3b file path
*/
bool loadBinary(const std::string& path);
/**
* load mesh data in binary
* @param meshdata The mesh data pointer
*/
bool loadMeshDataBinary(MeshData* meshdata);
/**
* load skin data in binary
* @param skindata The skin data pointer
*/
bool loadSkinDataBinary(SkinData* skindata);
/**
* load material data in binary
* @param materialdata The material pointer
*/
bool loadMaterialDataBinary(MaterialData* materialdata);
/**
* load animation data in binary
* @param animationdata The animation data pointer
*/
bool loadAnimationDataBinary(Animation3DData* animationdata);
protected:
/**
* get define data type
* @param str The type in string
*/
GLenum parseGLType(const std::string& str);
unsigned int parseGLTypeSize(const std::string& str);
/**
* get vertex attribute type
* @param str The type in string
*/
unsigned int parseGLProgramAttribute(const std::string& str);
// get model path
void getModelPath(const std::string& path);
/*
* get model path
* @param str Full path of model file
*/
void getModelRelativePath(const std::string& path);
/*
* set the read position in buffer to the target type
* @param The data type
*/
Reference* seekToFirstType(unsigned int type);
protected:
CC_CONSTRUCTOR_ACCESS:
Bundle3D();
~Bundle3D();
@ -102,11 +165,15 @@ protected:
std::string _modelRelativePath;
char* _documentBuffer;
char* _jsonBuffer;
std::string _path;
rapidjson::Document _document;
BundleReader* _bundleReader;
unsigned int _referenceCount;
Reference* _references;
Data* _binaryBuffer;
bool _isBinary;
};

View File

@ -34,7 +34,27 @@
NS_CC_BEGIN
/**mesh vertex attribute*/
// vertex usage elements.
enum Vertex_Usage
{
Vertex_Usage_POSITION = 1,
Vertex_Usage_NORMAL = 2,
Vertex_Usage_COLOR = 3,
Vertex_Usage_TANGENT = 4,
Vertex_Usage_BINORMAL = 5,
Vertex_Usage_BLENDWEIGHTS = 6,
Vertex_Usage_BLENDINDICES = 7,
Vertex_Usage_TEXCOORD0 = 8,
Vertex_Usage_TEXCOORD1 = 9,
Vertex_Usage_TEXCOORD2 = 10,
Vertex_Usage_TEXCOORD3 = 11,
Vertex_Usage_TEXCOORD4 = 12,
Vertex_Usage_TEXCOORD5 = 13,
Vertex_Usage_TEXCOORD6 = 14,
Vertex_Usage_TEXCOORD7 = 15
};
//mesh vertex attribute
struct MeshVertexAttrib
{
//attribute size
@ -47,7 +67,6 @@ struct MeshVertexAttrib
int attribSizeBytes;
};
/**mesh data*/
struct MeshData
{
std::vector<float> vertex;
@ -79,25 +98,17 @@ public:
}
};
/**skin data*/
struct SkinData
{
std::vector<std::string> skinBoneNames; //skin bones affect skin
std::vector<std::string> nodeBoneNames; //node bones don't affect skin, all bones [skinBone, nodeBone]
std::vector<Mat4> inverseBindPoseMatrices; //bind pose of skin bone, only for skin bone
std::vector<Mat4> skinBoneOriginMatrices; // original bone transform, for skin bone
std::vector<Mat4> nodeBoneOriginMatrices; // original bone transform, for node bone
std::vector<std::string> boneNames;
std::vector<Mat4> inverseBindPoseMatrices; //bind pose of bone
//bone child info, both skinbone and node bone
std::map<int, std::vector<int> > boneChild;//key parent, value child
int rootBoneIndex;
void resetData()
{
skinBoneNames.clear();
nodeBoneNames.clear();
boneNames.clear();
inverseBindPoseMatrices.clear();
skinBoneOriginMatrices.clear();
nodeBoneOriginMatrices.clear();
boneChild.clear();
rootBoneIndex = -1;
}
@ -105,30 +116,22 @@ struct SkinData
int getBoneNameIndex(const std::string& name)const
{
int i = 0;
for (auto iter : skinBoneNames)
for( const auto &item : boneNames )
{
if ((iter) == name)
if (item == name)
return i;
i++;
}
for(auto iter : nodeBoneNames)
{
if (iter == name)
return i;
i++;
else
++i;
}
return -1;
}
};
/**material data*/
struct MaterialData
{
std::string texturePath;
};
/**animation data*/
struct Animation3DData
{
public:
@ -198,6 +201,17 @@ public:
}
};
class Reference
{
public:
std::string id;
unsigned int type;
unsigned int offset;
Reference(){};
~Reference(){};
};
NS_CC_END
#endif //__CC_BUNDLE_3D_DATA_H__

211
cocos/3d/CCBundleReader.cpp Normal file
View File

@ -0,0 +1,211 @@
#include "CCBundleReader.h"
#include "platform/CCFileUtils.h"
NS_CC_BEGIN
BundleReader::~BundleReader()
{
close();
};
BundleReader* BundleReader::create(char* lpbuffer, unsigned int length)
{
if (lpbuffer)
{
BundleReader* stream = new BundleReader();
stream->init(lpbuffer, length);
return stream;
}
return NULL;
}
void BundleReader::close()
{
CC_SAFE_DELETE(m_buffer);
}
size_t BundleReader::read(void* ptr, size_t size, size_t count)
{
if (!m_buffer || eof())
return 0;
size_t validCount;
size_t validLength = m_length - m_position;
size_t needLength = size*count;
char* ptr1 = (char*)ptr;
if(validLength <= needLength)
{
validCount = validLength/size;
size_t readLength = size*validCount;
memcpy(ptr1,(char*)m_buffer+m_position,readLength);
ptr1 += readLength;
m_position += readLength;
readLength = validLength - readLength;
if(readLength>0)
{
memcpy(ptr1,(char*)m_buffer+m_position,readLength);
m_position += readLength;
validCount+=1;
}
}
else
{
memcpy(ptr1,(char*)m_buffer+m_position,needLength);
m_position += needLength;
validCount = count;
}
//*ptr1 = 0;
return validCount;
}
char* BundleReader::readLine(int num,char* line)
{
if (!m_buffer)
return 0;
//char* str = new char[num];
char* buffer = (char*)m_buffer+m_position;
char* p = line;
char c;
size_t readNum = 0;
while((c=*buffer) != 10 && readNum < (size_t)num && m_position<(long int)m_length)
{
*p = c;
p++;
buffer++;
m_position++;
readNum++;
}
*p = '\0';
return line;
}
size_t BundleReader::write(const void* ptr, size_t size, size_t count)
{
if (!m_buffer)
return 0;
size_t validCount;
size_t validLength = m_length - m_position;
size_t needLength = size*count;
const char* ptr1 = (const char*)ptr;
if (validLength <= needLength)
{
validCount = validLength / size;
size_t readLength = size * validCount;
memcpy((char*)m_buffer + m_position, ptr1, readLength);
ptr1 += readLength;
m_position += readLength;
readLength = validLength - readLength;
if(readLength > 0)
{
memcpy((char*)m_buffer+m_position, ptr1, readLength);
m_position += readLength;
validCount += 1;
}
}
else
{
memcpy((char*)m_buffer + m_position, ptr1, needLength);
m_position += needLength;
validCount = count;
}
return validCount;
}
bool BundleReader::eof()
{
if (!m_buffer)
return true;
return ((size_t)tell()) >= length();
}
size_t BundleReader::length()
{
return m_length;
}
long int BundleReader::tell()
{
if (!m_buffer)
return -1;
return m_position;
}
bool BundleReader::seek(long int offset, int origin)
{
if (!m_buffer)
return false;
if(origin == SEEK_CUR)
{
m_position += offset;
}
else if(origin == SEEK_SET)
{
m_position = offset;
}
else if(origin == SEEK_END)
{
m_position = m_length+offset;
}
else
return false;
return true;
}
bool BundleReader::rewind()
{
if (m_buffer != NULL)
{
m_position = 0;
return true;
}
return false;
}
std::string BundleReader::readString()
{
unsigned int length;
if(read(&length, 4, 1) != 1)
{
return std::string();
}
std::string str;
if (length > 0)
{
str.resize(length);
if (read(&str[0], 1, length) != length)
{
return std::string();
}
}
return str;
}
bool BundleReader::readMatrix(float* m)
{
return (read(m, sizeof(float), 16) == 16);
}
BundleReader::BundleReader()
{
m_buffer = NULL;
m_position = 0;
m_length = 0;
};
void BundleReader::init(char* lpbuffer, unsigned int length)
{
m_position = 0;
m_buffer = lpbuffer;
m_length = length;
}
}

213
cocos/3d/CCBundleReader.h Normal file
View File

@ -0,0 +1,213 @@
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.
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 __CC_BUNDLE_READER_H__
#define __CC_BUNDLE_READER_H__
#include <string>
#include <vector>
#include "base/CCRef.h"
#include "base/CCPlatformMacros.h"
#include "base/CCConsole.h"
NS_CC_BEGIN
/**
* BundleReader is an interface for reading sequence of bytes.
*/
class BundleReader: public cocos2d::Ref
{
public:
/**
* Destructor
*/
~BundleReader();
/** creates an BundleReader with lpbuffer and length
* @param lpbuffer The pointer to the file data
* @param length The size for lpbuffer in bytes
*/
static BundleReader* create(char* lpbuffer, unsigned int length);
/**
* Close and delete buffer
*/
void close();
/**
* Reads an array of elements.
*
* @param ptr The pointer to the memory to copy into.
* The available size should be at least bytes.
* @param size The size of each element to be read, in bytes.
* @param count The number of elements to read.
*
* @return The number of elements read.
*/
size_t read(void* ptr, size_t size, size_t count);
/**
* Reads a line from the buffer.
*/
char* readLine(int num, char* line);
/**
* Writes an array of elements.
*
* @param ptr The pointer to the array of elements to be written.
* @param size The size of each element to be written, in bytes.
* @param count The number of elements to write.
*
* @return The number of elements written.
*/
size_t write(const void* ptr, size_t size, size_t count);
/**
* Returns true if the end of the buffer has been reached.
*/
bool eof();
/**
* Returns the length of the buffer in bytes.
*/
size_t length();
/**
* Returns the position of the file pointer.
*/
long int tell();
/**
* Sets the position of the file pointer.
*/
bool seek(long int offset, int origin);
/**
* Sets the file pointer at the start of the file.
*/
bool rewind();
/**
* read binary typed value.
*/
template<typename T> bool read(T* ptr);
template<typename T> bool readArray(unsigned int* length, std::vector<T>* values);
/**
* first read length, then read string text
*/
std::string readString();
bool readMatrix(float* m);
private:
BundleReader();
void init(char* lpbuffer, unsigned int length);
private:
long int m_position;
size_t m_length;
char* m_buffer;
};
// template read routines
template<typename T>
inline bool BundleReader::read(T *ptr)
{
return (read(ptr, sizeof(T), 1) == 1);
}
/**
* template function to read array of value.
*/
template<typename T>
inline bool BundleReader::readArray(unsigned int *length, std::vector<T> *values)
{
if (!read(length))
{
return false;
}
if (*length > 0 && values)
{
values->resize(*length);
if (read(&(*values)[0], sizeof(T), *length) != *length)
{
return false;
}
}
return true;
}
/**
* specalization for char
*/
template<>
inline bool BundleReader::read<char>(char *ptr)
{
if (read(ptr, sizeof(char), 1) == 1)
{
return true;
}
else
{
*ptr = -1;
return false;
}
}
/**
* specalization for std::string
*/
template<>
inline bool BundleReader::read<std::string>(std::string *ptr)
{
CCLOG("can not read std::string, use readString() instead");
return false;
}
/**
* template function to read array of value.
*/
template<>
inline bool BundleReader::readArray<std::string>(unsigned int *length, std::vector<std::string> *values)
{
if (!read(length))
{
return false;
}
values->clear();
if (*length > 0 && values)
{
for (int i = 0; i < (int)*length; ++i)
{
values->push_back(readString());
}
}
return true;
}
NS_CC_END
#endif

View File

@ -301,14 +301,14 @@ MeshSkin* MeshSkin::create(const std::string& filename, const std::string& name)
bool MeshSkin::initFromSkinData(const SkinData& skindata)
{
ssize_t i = 0;
for (; i < skindata.skinBoneNames.size(); i++) {
auto bone = Bone::create(skindata.skinBoneNames[i]);
for (; i < skindata.boneNames.size(); i++) {
auto bone = Bone::create(skindata.boneNames[i]);
bone->_invBindPose = skindata.inverseBindPoseMatrices[i];
//bone->setOriPose(skindata.skinBoneOriginMatrices[i]);
addSkinBone(bone);
}
for (i = 0; i < skindata.nodeBoneNames.size(); i++) {
auto bone = Bone::create(skindata.nodeBoneNames[i]);
for (i = 0; i < skindata.boneNames.size(); i++) {
auto bone = Bone::create(skindata.boneNames[i]);
//bone->setOriPose(skindata.nodeBoneOriginMatrices[i]);
addNodeBone(bone);
}

View File

@ -22,6 +22,7 @@
THE SOFTWARE.
****************************************************************************/
#include "base/CCConsole.h"
#include "base/CCEventListener.h"
#include "platform/CCCommon.h"

View File

@ -26,6 +26,7 @@
#define __CCINTEGER_H__
#include "base/CCRef.h"
#include "base/CCConsole.h"
#include "base/CCDataVisitor.h"
#include "platform/CCCommon.h"

View File

@ -0,0 +1,278 @@
/****************************************************************************
Copyright (c) 2013 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.
****************************************************************************/
#include "CCActionTimeline.h"
USING_NS_CC;
NS_TIMELINE_BEGIN
// ActionTimelineData
ActionTimelineData* ActionTimelineData::create(int actionTag)
{
ActionTimelineData * ret = new ActionTimelineData();
if (ret && ret->init(actionTag))
{
ret->autorelease();
}
else
{
CC_SAFE_DELETE(ret);
}
return ret;
}
ActionTimelineData::ActionTimelineData()
: _actionTag(0)
{
}
bool ActionTimelineData::init(int actionTag)
{
_actionTag = actionTag;
return true;
}
// ActionTimeline
ActionTimeline* ActionTimeline::create()
{
ActionTimeline* object = new ActionTimeline();
if (object && object->init())
{
object->autorelease();
return object;
}
CC_SAFE_DELETE(object);
return nullptr;
}
ActionTimeline::ActionTimeline()
: _duration(0)
, _time(0)
, _timeSpeed(1)
, _frameInternal(1/60.0f)
, _playing(false)
, _currentFrame(0)
, _startFrame(0)
, _endFrame(0)
, _frameEventListener(nullptr)
{
}
ActionTimeline::~ActionTimeline()
{
}
bool ActionTimeline::init()
{
return true;
}
void ActionTimeline::gotoFrameAndPlay(int startIndex)
{
gotoFrameAndPlay(startIndex, true);
}
void ActionTimeline::gotoFrameAndPlay(int startIndex, bool loop)
{
gotoFrameAndPlay(startIndex, _duration, loop);
}
void ActionTimeline::gotoFrameAndPlay(int startIndex, int endIndex, bool loop)
{
_startFrame = _currentFrame = startIndex;
_endFrame = endIndex;
_loop = loop;
_time = _currentFrame * _frameInternal;
resume();
gotoFrame(_currentFrame);
}
void ActionTimeline::gotoFrameAndPause(int startIndex)
{
_startFrame = _currentFrame = startIndex;
_time = _currentFrame * _frameInternal;
pause();
gotoFrame(_currentFrame);
}
void ActionTimeline::pause()
{
_playing = false;
}
void ActionTimeline::resume()
{
_playing = true;
}
bool ActionTimeline::isPlaying() const
{
return _playing;
}
ActionTimeline* ActionTimeline::clone() const
{
ActionTimeline* newAction = ActionTimeline::create();
newAction->setDuration(_duration);
newAction->setTimeSpeed(_timeSpeed);
for (auto timelines : _timelineMap)
{
for(auto timeline : timelines.second)
{
Timeline* newTimeline = timeline->clone();
newAction->addTimeline(newTimeline);
}
}
return newAction;
}
void ActionTimeline::step(float delta)
{
if (!_playing || _timelineMap.size() == 0 || _duration == 0)
{
return;
}
_time += delta * _timeSpeed;
_currentFrame = (int)(_time / _frameInternal);
stepToFrame(_currentFrame);
if(_time > _endFrame * _frameInternal)
{
_playing = _loop;
if(!_playing)
_time = _endFrame * _frameInternal;
else
_time = _startFrame * _frameInternal;
}
}
typedef std::function<void(Node*)> tCallBack;
void foreachNodeDescendant(Node* parent, tCallBack callback)
{
callback(parent);
auto children = parent->getChildren();
for (auto child : children)
{
foreachNodeDescendant(child, callback);
}
}
void ActionTimeline::startWithTarget(Node *target)
{
Action::startWithTarget(target);
foreachNodeDescendant(target,
[this, target](Node* child)
{
ActionTimelineData* data = dynamic_cast<ActionTimelineData*>(child->getUserObject());
int actionTag = data->getActionTag();
if(_timelineMap.find(actionTag) != _timelineMap.end())
{
auto timelines = this->_timelineMap[actionTag];
for (auto timeline : timelines)
{
timeline->setNode(child);
}
}
});
}
void ActionTimeline::addTimeline(Timeline* timeline)
{
int tag = timeline->getActionTag();
if (_timelineMap.find(tag) == _timelineMap.end())
{
_timelineMap[tag] = Vector<Timeline*>();
}
if (!_timelineMap[tag].contains(timeline))
{
_timelineList.pushBack(timeline);
_timelineMap[tag].pushBack(timeline);
timeline->setActionTimeline(this);
}
}
void ActionTimeline::removeTimeline(Timeline* timeline)
{
int tag = timeline->getActionTag();
if (_timelineMap.find(tag) != _timelineMap.end())
{
if(_timelineMap[tag].contains(timeline))
{
_timelineMap[tag].eraseObject(timeline);
_timelineList.eraseObject(timeline);
timeline->setActionTimeline(nullptr);
}
}
}
void ActionTimeline::setFrameEventCallFunc(std::function<void(Frame *)> listener)
{
_frameEventListener = listener;
}
void ActionTimeline::clearFrameEventCallFunc()
{
_frameEventListener = nullptr;
}
void ActionTimeline::emitFrameEvent(Frame* frame)
{
if(_frameEventListener)
{
_frameEventListener(frame);
}
}
void ActionTimeline::gotoFrame(int frameIndex)
{
int size = _timelineList.size();
for(int i = 0; i<size; i++)
{
_timelineList.at(i)->gotoFrame(frameIndex);
}
}
void ActionTimeline::stepToFrame(int frameIndex)
{
int size = _timelineList.size();
for(int i = 0; i<size; i++)
{
_timelineList.at(i)->stepToFrame(frameIndex);
}
}
NS_TIMELINE_END

View File

@ -0,0 +1,160 @@
/****************************************************************************
Copyright (c) 2013 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 __CCTIMELINE_ACTION_H__
#define __CCTIMELINE_ACTION_H__
#include "CCTimeLine.h"
#include "renderer/CCRenderer.h"
NS_TIMELINE_BEGIN
class ActionTimelineData : public cocos2d::Ref
{
public:
static ActionTimelineData* create(int actionTag);
virtual void setActionTag(int actionTag) { _actionTag = actionTag; }
virtual int getActionTag() const { return _actionTag; }
protected:
ActionTimelineData();
virtual bool init(int actionTag);
int _actionTag;
};
class ActionTimeline : public cocos2d::Action
{
public:
friend class Frame;
static ActionTimeline* create();
ActionTimeline();
virtual ~ActionTimeline();
virtual bool init();
/** Goto the specified frame index, and start playing from this index.
* @param startIndex The animation will play from this index.
*/
virtual void gotoFrameAndPlay(int startIndex);
/** Goto the specified frame index, and start playing from this index.
* @param startIndex The animation will play from this index.
* @param loop Whether or not the animation need loop.
*/
virtual void gotoFrameAndPlay(int startIndex, bool loop);
/** Goto the specified frame index, and start playing from start index, end at end index.
* @param startIndex The animation will play from this index.
* @param endIndex The animation will end at this index.
* @param loop Whether or not the animation need loop.
*/
virtual void gotoFrameAndPlay(int startIndex, int endIndex, bool loop);
/** Goto the specified frame index, and pause at this index.
* @param startIndex The animation will pause at this index.
*/
virtual void gotoFrameAndPause(int startIndex);
/** Pause the animation. */
virtual void pause();
/** Resume the animation. */
virtual void resume();
/** Whether or not Action is playing. */
virtual bool isPlaying() const;
/** Set the animation speed, this will speed up or slow down the speed. */
virtual void setTimeSpeed(float speed) { _timeSpeed = speed; }
/** Get current animation speed. */
virtual float getTimeSpeed() const { return _timeSpeed; }
/** duration of the whole action*/
virtual void setDuration(int duration) { _duration = duration; }
virtual int getDuration() const { return _duration; }
/** Start frame index of this action*/
virtual int getStartFrame() const { return _startFrame; }
/** End frame of this action.
* When action play to this frame, if action is not loop, then it will stop,
* or it will play from start frame again. */
virtual int getEndFrame() const { return _endFrame; }
/** Get current frame. */
virtual int getCurrentFrame() const { return _currentFrame; }
/** add Timeline to ActionTimeline */
virtual void addTimeline(Timeline* timeline);
virtual void removeTimeline(Timeline* timeline);
virtual const cocos2d::Vector<Timeline*>& getTimelines() const { return _timelineList; }
/** Set ActionTimeline's frame event callback function */
void setFrameEventCallFunc(std::function<void(Frame *)> listener);
void clearFrameEventCallFunc();
/** Inherit from Action. */
/** Returns a clone of ActionTimeline */
virtual ActionTimeline* clone() const override;
/** Returns a reverse of ActionTimeline.
* Not implement yet.
*/
virtual ActionTimeline* reverse() const override { return nullptr; }
virtual void step(float delta) override;
virtual void startWithTarget(cocos2d::Node *target) override;
virtual bool isDone() const override { return false; }
protected:
virtual void gotoFrame(int frameIndex);
virtual void stepToFrame(int frameIndex);
/** emit frame event, call it when enter a frame*/
virtual void emitFrameEvent(Frame* frame);
std::map<int, cocos2d::Vector<Timeline*>> _timelineMap;
cocos2d::Vector<Timeline*> _timelineList;
int _duration;
double _time;
float _timeSpeed;
float _frameInternal;
bool _playing;
int _currentFrame;
int _startFrame;
int _endFrame;
bool _loop;
std::function<void(Frame*)> _frameEventListener;
};
NS_TIMELINE_END
#endif /*__CCTIMELINE_ACTION_H__*/

View File

@ -0,0 +1,374 @@
/****************************************************************************
Copyright (c) 2013 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.
****************************************************************************/
#include "CCActionTimelineCache.h"
#include "CCNodeReader.h"
#include "CCFrame.h"
#include "CCTimeLine.h"
#include "CCActionTimeline.h"
using namespace cocos2d;
namespace cocostudio {
namespace timeline{
static const char* FrameType_VisibleFrame = "VisibleFrame";
static const char* FrameType_PositionFrame = "PositionFrame";
static const char* FrameType_ScaleFrame = "ScaleFrame";
static const char* FrameType_RotationFrame = "RotationFrame";
static const char* FrameType_SkewFrame = "SkewFrame";
static const char* FrameType_RotationSkewFrame = "RotationSkewFrame";
static const char* FrameType_AnchorFrame = "AnchorFrame";
static const char* FrameType_InnerActionFrame = "InnerActionFrame";
static const char* FrameType_ColorFrame = "ColorFrame";
static const char* FrameType_TextureFrame = "TextureFrame";
static const char* FrameType_EventFrame = "EventFrame";
static const char* FrameType_ZOrderFrame = "ZOrderFrame";
static const char* ACTION = "action";
static const char* DURATION = "duration";
static const char* TIMELINES = "timelines";
static const char* FRAME_TYPE = "frameType";
static const char* FRAMES = "frames";
static const char* FRAME_INDEX = "frameIndex";
static const char* TWEEN = "tween";
static const char* TIME_SPEED = "speed";
static const char* ACTION_TAG = "actionTag";
static const char* INNER_ACTION = "innerActionType";
static const char* START_FRAME = "startFrame";
static const char* X = "x";
static const char* Y = "y";
static const char* ROTATION = "rotation";
static const char* ALPHA = "alpha";
static const char* RED = "red";
static const char* GREEN = "green";
static const char* BLUE = "blue";
static const char* Value = "value";
static ActionTimelineCache* _sharedActionCache = nullptr;
ActionTimelineCache* ActionTimelineCache::getInstance()
{
if (! _sharedActionCache)
{
_sharedActionCache = new ActionTimelineCache();
_sharedActionCache->init();
}
return _sharedActionCache;
}
void ActionTimelineCache::destroyInstance()
{
CC_SAFE_DELETE(_sharedActionCache);
}
void ActionTimelineCache::purge()
{
_animationActions.clear();
}
void ActionTimelineCache::init()
{
using namespace std::placeholders;
_funcs.insert(Pair(FrameType_VisibleFrame, std::bind(&ActionTimelineCache::loadVisibleFrame, this, _1)));
_funcs.insert(Pair(FrameType_PositionFrame, std::bind(&ActionTimelineCache::loadPositionFrame, this, _1)));
_funcs.insert(Pair(FrameType_ScaleFrame, std::bind(&ActionTimelineCache::loadScaleFrame, this, _1)));
_funcs.insert(Pair(FrameType_RotationFrame, std::bind(&ActionTimelineCache::loadRotationFrame, this, _1)));
_funcs.insert(Pair(FrameType_SkewFrame, std::bind(&ActionTimelineCache::loadSkewFrame, this, _1)));
_funcs.insert(Pair(FrameType_RotationSkewFrame, std::bind(&ActionTimelineCache::loadRotationSkewFrame, this, _1)));
_funcs.insert(Pair(FrameType_AnchorFrame, std::bind(&ActionTimelineCache::loadAnchorPointFrame, this, _1)));
_funcs.insert(Pair(FrameType_InnerActionFrame, std::bind(&ActionTimelineCache::loadInnerActionFrame, this, _1)));
_funcs.insert(Pair(FrameType_ColorFrame, std::bind(&ActionTimelineCache::loadColorFrame, this, _1)));
_funcs.insert(Pair(FrameType_TextureFrame, std::bind(&ActionTimelineCache::loadTextureFrame, this, _1)));
_funcs.insert(Pair(FrameType_EventFrame, std::bind(&ActionTimelineCache::loadEventFrame, this, _1)));
_funcs.insert(Pair(FrameType_ZOrderFrame, std::bind(&ActionTimelineCache::loadZOrderFrame, this, _1)));
}
void ActionTimelineCache::removeAction(const std::string& fileName)
{
if (_animationActions.find(fileName) != _animationActions.end())
{
_animationActions.erase(fileName);
}
}
ActionTimeline* ActionTimelineCache::createAction(const std::string& fileName)
{
ActionTimeline* action = _animationActions.at(fileName);
if (action == nullptr)
{
action = loadAnimationActionWithFile(fileName);
}
return action->clone();
}
ActionTimeline* ActionTimelineCache::loadAnimationActionWithFile(const std::string& fileName)
{
// Read content from file
std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(fileName);
std::string contentStr = FileUtils::getInstance()->getStringFromFile(fullPath);
return loadAnimationActionWithContent(fileName, contentStr);
}
ActionTimeline* ActionTimelineCache::loadAnimationActionWithContent(const std::string&fileName, const std::string& content)
{
// if already exists an action with filename, then return this action
ActionTimeline* action = _animationActions.at(fileName);
if(action)
return action;
rapidjson::Document doc;
doc.Parse<0>(content.c_str());
if (doc.HasParseError())
{
CCLOG("GetParseError %s\n", doc.GetParseError());
}
const rapidjson::Value& json = DICTOOL->getSubDictionary_json(doc, ACTION);
action = ActionTimeline::create();
action->setDuration(DICTOOL->getIntValue_json(json, DURATION));
action->setTimeSpeed(DICTOOL->getFloatValue_json(json, TIME_SPEED, 1.0f));
int timelineLength = DICTOOL->getArrayCount_json(json, TIMELINES);
for (int i = 0; i<timelineLength; i++)
{
const rapidjson::Value& dic = DICTOOL->getSubDictionary_json(json, TIMELINES, i);
Timeline* timeline = loadTimeline(dic);
if(timeline)
action->addTimeline(timeline);
}
_animationActions.insert(fileName, action);
return action;
}
Timeline* ActionTimelineCache::loadTimeline(const rapidjson::Value& json)
{
Timeline* timeline = nullptr;
// get frame type
const char* frameType = DICTOOL->getStringValue_json(json, FRAME_TYPE);
if(frameType == nullptr)
return nullptr;
if(frameType && _funcs.find(frameType) != _funcs.end())
{
timeline = Timeline::create();
int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG);
timeline->setActionTag(actionTag);
FrameCreateFunc func = _funcs.at(frameType);
int length = DICTOOL->getArrayCount_json(json, FRAMES);
for (int i = 0; i<length; i++)
{
const rapidjson::Value& dic = DICTOOL->getSubDictionary_json(json, FRAMES, i);
Frame* frame = nullptr;
if (func != nullptr)
{
frame = func(dic);
int frameIndex = DICTOOL->getIntValue_json(dic, FRAME_INDEX);
frame->setFrameIndex(frameIndex);
bool tween = DICTOOL->getBooleanValue_json(dic, TWEEN, false);
frame->setTween(tween);
}
timeline->addFrame(frame);
}
}
return timeline;
}
Frame* ActionTimelineCache::loadVisibleFrame(const rapidjson::Value& json)
{
VisibleFrame* frame = VisibleFrame::create();
bool visible = DICTOOL->getBooleanValue_json(json, Value);
frame->setVisible(visible);
return frame;
}
Frame* ActionTimelineCache::loadPositionFrame(const rapidjson::Value& json)
{
PositionFrame* frame = PositionFrame::create();
float x = DICTOOL->getFloatValue_json(json, X);
float y = DICTOOL->getFloatValue_json(json, Y);
frame->setPosition(Point(x,y));
return frame;
}
Frame* ActionTimelineCache::loadScaleFrame(const rapidjson::Value& json)
{
ScaleFrame* frame = ScaleFrame::create();
float scalex = DICTOOL->getFloatValue_json(json, X);
float scaley = DICTOOL->getFloatValue_json(json, Y);
frame->setScaleX(scalex);
frame->setScaleY(scaley);
return frame;
}
Frame* ActionTimelineCache::loadSkewFrame(const rapidjson::Value& json)
{
SkewFrame* frame = SkewFrame::create();
float skewx = DICTOOL->getFloatValue_json(json, X);
float skewy = DICTOOL->getFloatValue_json(json, Y);
frame->setSkewX(skewx);
frame->setSkewY(skewy);
return frame;
}
Frame* ActionTimelineCache::loadRotationSkewFrame(const rapidjson::Value& json)
{
RotationSkewFrame* frame = RotationSkewFrame::create();
float skewx = DICTOOL->getFloatValue_json(json, X);
float skewy = DICTOOL->getFloatValue_json(json, Y);
frame->setSkewX(skewx);
frame->setSkewY(skewy);
return frame;
}
Frame* ActionTimelineCache::loadRotationFrame(const rapidjson::Value& json)
{
RotationFrame* frame = RotationFrame::create();
float rotation = DICTOOL->getFloatValue_json(json, ROTATION);
frame->setRotation(rotation);
return frame;
}
Frame* ActionTimelineCache::loadAnchorPointFrame (const rapidjson::Value& json)
{
AnchorPointFrame* frame = AnchorPointFrame::create();
float anchorx = DICTOOL->getFloatValue_json(json, X);
float anchory = DICTOOL->getFloatValue_json(json, Y);
frame->setAnchorPoint(Point(anchorx, anchory));
return frame;
}
Frame* ActionTimelineCache::loadInnerActionFrame(const rapidjson::Value& json)
{
InnerActionFrame* frame = InnerActionFrame::create();
InnerActionType type = (InnerActionType)DICTOOL->getIntValue_json(json, INNER_ACTION);
int startFrame = DICTOOL->getIntValue_json(json, START_FRAME);
frame->setInnerActionType(type);
frame->setStartFrameIndex(startFrame);
return frame;
}
Frame* ActionTimelineCache::loadColorFrame(const rapidjson::Value& json)
{
ColorFrame* frame = ColorFrame::create();
GLubyte alpha = (GLubyte)DICTOOL->getIntValue_json(json, ALPHA);
GLubyte red = (GLubyte)DICTOOL->getIntValue_json(json, RED);
GLubyte green = (GLubyte)DICTOOL->getIntValue_json(json, GREEN);
GLubyte blue = (GLubyte)DICTOOL->getIntValue_json(json, BLUE);
frame->setAlpha(alpha);
frame->setColor(Color3B(red, green, blue));
return frame;
}
Frame* ActionTimelineCache::loadTextureFrame(const rapidjson::Value& json)
{
TextureFrame* frame = TextureFrame::create();
const char* texture = DICTOOL->getStringValue_json(json, Value);
if(texture != NULL)
{
std::string path = texture;
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(path);
if(spriteFrame == nullptr)
{
std::string jsonPath = NodeReader::getInstance()->getJsonPath();
path = jsonPath + texture;
}
frame->setTextureName(path);
}
return frame;
}
Frame* ActionTimelineCache::loadEventFrame(const rapidjson::Value& json)
{
EventFrame* frame = EventFrame::create();
const char* evnt = DICTOOL->getStringValue_json(json, Value);
if(evnt != NULL)
frame->setEvent(evnt);
return frame;
}
Frame* ActionTimelineCache::loadZOrderFrame(const rapidjson::Value& json)
{
ZOrderFrame* frame = ZOrderFrame::create();
int zorder = DICTOOL->getIntValue_json(json, Value);
frame->setZOrder(zorder);
return frame;
}
}
}

View File

@ -0,0 +1,87 @@
/****************************************************************************
Copyright (c) 2013 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 __CCTIMELINE_ACTION_CACHE_H__
#define __CCTIMELINE_ACTION_CACHE_H__
#include "cocos2d.h"
#include "cocostudio/DictionaryHelper.h"
#include "CCTimelineMacro.h"
NS_TIMELINE_BEGIN
class ActionTimeline;
class Timeline;
class Frame;
class ActionTimelineCache
{
public:
/** Gets the singleton */
static ActionTimelineCache* getInstance();
/** Destroys the singleton */
static void destroyInstance();
void purge();
void init();
/** Remove action with filename, and also remove other resource relate with this file */
void removeAction(const std::string& fileName);
/** Clone a action with the specified name from the container. */
ActionTimeline* createAction(const std::string& fileName);
ActionTimeline* loadAnimationActionWithFile(const std::string& fileName);
ActionTimeline* loadAnimationActionWithContent(const std::string&fileName, const std::string& content);
protected:
Timeline* loadTimeline(const rapidjson::Value& json);
Frame* loadVisibleFrame (const rapidjson::Value& json);
Frame* loadPositionFrame (const rapidjson::Value& json);
Frame* loadScaleFrame (const rapidjson::Value& json);
Frame* loadSkewFrame (const rapidjson::Value& json);
Frame* loadRotationSkewFrame(const rapidjson::Value& json);
Frame* loadRotationFrame (const rapidjson::Value& json);
Frame* loadAnchorPointFrame (const rapidjson::Value& json);
Frame* loadInnerActionFrame (const rapidjson::Value& json);
Frame* loadColorFrame (const rapidjson::Value& json);
Frame* loadTextureFrame (const rapidjson::Value& json);
Frame* loadEventFrame (const rapidjson::Value& json);
Frame* loadZOrderFrame (const rapidjson::Value& json);
protected:
typedef std::function<Frame*(const rapidjson::Value& json)> FrameCreateFunc;
typedef std::pair<std::string, FrameCreateFunc> Pair;
std::unordered_map<std::string, FrameCreateFunc> _funcs;
cocos2d::Map<std::string, ActionTimeline*> _animationActions;
};
NS_TIMELINE_END
#endif /*__CCTIMELINE_ACTION_CACHE_H__*/

View File

@ -0,0 +1,622 @@
/****************************************************************************
Copyright (c) 2013 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.
****************************************************************************/
#include "CCFrame.h"
#include "CCTimeLine.h"
#include "CCActionTimeline.h"
USING_NS_CC;
NS_TIMELINE_BEGIN
// Frame
Frame::Frame()
: _frameIndex(0)
, _tween(true)
, _timeline(nullptr)
, _node(nullptr)
{
}
Frame::~Frame()
{
}
void Frame::emitEvent()
{
if (_timeline)
{
_timeline->getActionTimeline()->emitFrameEvent(this);
}
}
void Frame::cloneProperty(Frame* frame)
{
_frameIndex = frame->getFrameIndex();
_tween = frame->isTween();
}
// VisibleFrame
VisibleFrame* VisibleFrame::create()
{
VisibleFrame* frame = new VisibleFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
VisibleFrame::VisibleFrame()
: _visible(true)
{
}
void VisibleFrame::onEnter(Frame *nextFrame)
{
_node->setVisible(_visible);
}
Frame* VisibleFrame::clone()
{
VisibleFrame* frame = VisibleFrame::create();
frame->setVisible(_visible);
frame->cloneProperty(this);
return frame;
}
// TextureFrame
TextureFrame* TextureFrame::create()
{
TextureFrame* frame = new TextureFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
TextureFrame::TextureFrame()
: _textureName("")
{
}
void TextureFrame::setNode(Node* node)
{
Frame::setNode(node);
_sprite = dynamic_cast<Sprite*>(node);
}
void TextureFrame::onEnter(Frame *nextFrame)
{
if(_sprite)
{
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(_textureName);
if(spriteFrame != nullptr)
_sprite->setSpriteFrame(spriteFrame);
else
_sprite->setTexture(_textureName);
}
}
Frame* TextureFrame::clone()
{
TextureFrame* frame = TextureFrame::create();
frame->setTextureName(_textureName);
frame->cloneProperty(this);
return frame;
}
// RotationFrame
RotationFrame* RotationFrame::create()
{
RotationFrame* frame = new RotationFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
RotationFrame::RotationFrame()
: _rotation(0)
{
}
void RotationFrame::onEnter(Frame *nextFrame)
{
_node->setRotation(_rotation);
if(_tween)
{
_betwennRotation = static_cast<RotationFrame*>(nextFrame)->_rotation - _rotation;
}
}
void RotationFrame::apply(float percent)
{
if (_tween && percent != 0 || _betwennRotation != 0)
{
float rotation = _rotation + percent * _betwennRotation;
_node->setRotation(rotation);
}
}
Frame* RotationFrame::clone()
{
RotationFrame* frame = RotationFrame::create();
frame->setRotation(_rotation);
frame->cloneProperty(this);
return frame;
}
// SkewFrame
SkewFrame* SkewFrame::create()
{
SkewFrame* frame = new SkewFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
SkewFrame::SkewFrame()
: _skewX(0)
, _skewY(0)
{
}
void SkewFrame::onEnter(Frame *nextFrame)
{
_node->setSkewX(_skewX);
_node->setSkewY(_skewY);
if(_tween)
{
_betweenSkewX = static_cast<SkewFrame*>(nextFrame)->_skewX - _skewX;
_betweenSkewY = static_cast<SkewFrame*>(nextFrame)->_skewY - _skewY;
}
}
void SkewFrame::apply(float percent)
{
if (_tween && percent != 0 || (_betweenSkewX != 0 || _betweenSkewY != 0))
{
float skewx = _skewX + percent * _betweenSkewX;
float skewy = _skewY + percent * _betweenSkewY;
_node->setSkewX(skewx);
_node->setSkewY(skewy);
}
}
Frame* SkewFrame::clone()
{
SkewFrame* frame = SkewFrame::create();
frame->setSkewX(_skewX);
frame->setSkewY(_skewY);
frame->cloneProperty(this);
return frame;
}
// RotationSkewFrame
RotationSkewFrame* RotationSkewFrame::create()
{
RotationSkewFrame* frame = new RotationSkewFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
RotationSkewFrame::RotationSkewFrame()
{
}
void RotationSkewFrame::onEnter(Frame *nextFrame)
{
_node->setRotationSkewX(_skewX);
_node->setRotationSkewY(_skewY);
if (_tween)
{
_betweenSkewX = static_cast<RotationSkewFrame*>(nextFrame)->_skewX - _skewX;
_betweenSkewY = static_cast<RotationSkewFrame*>(nextFrame)->_skewY - _skewY;
}
}
void RotationSkewFrame::apply(float percent)
{
if (_tween && percent != 0 || (_betweenSkewX != 0 || _betweenSkewY != 0))
{
float skewx = _skewX + percent * _betweenSkewX;
float skewy = _skewY + percent * _betweenSkewY;
_node->setRotationSkewX(skewx);
_node->setRotationSkewY(skewy);
}
}
Frame* RotationSkewFrame::clone()
{
RotationSkewFrame* frame = RotationSkewFrame::create();
frame->setSkewX(_skewX);
frame->setSkewY(_skewY);
frame->cloneProperty(this);
return frame;
}
// PositionFrame
PositionFrame* PositionFrame::create()
{
PositionFrame* frame = new PositionFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
PositionFrame::PositionFrame()
: _position(0,0)
{
}
void PositionFrame::onEnter(Frame *nextFrame)
{
_node->setPosition(_position);
if(_tween)
{
_betweenX = static_cast<PositionFrame*>(nextFrame)->_position.x - _position.x;
_betweenY = static_cast<PositionFrame*>(nextFrame)->_position.y - _position.y;
}
}
void PositionFrame::apply(float percent)
{
if (_tween && percent != 0 || (_betweenX != 0 || _betweenY != 0))
{
Point p;
p.x = _position.x + _betweenX * percent;
p.y = _position.y + _betweenY * percent;
_node->setPosition(p);
}
}
Frame* PositionFrame::clone()
{
PositionFrame* frame = PositionFrame::create();
frame->setPosition(_position);
frame->cloneProperty(this);
return frame;
}
// ScaleFrame
ScaleFrame* ScaleFrame::create()
{
ScaleFrame* frame = new ScaleFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
ScaleFrame::ScaleFrame()
: _scaleX(1)
, _scaleY(1)
{
}
void ScaleFrame::onEnter(Frame *nextFrame)
{
_node->setScaleX(_scaleX);
_node->setScaleY(_scaleY);
if(_tween)
{
_betweenScaleX = static_cast<ScaleFrame*>(nextFrame)->_scaleX - _scaleX;
_betweenScaleY = static_cast<ScaleFrame*>(nextFrame)->_scaleY - _scaleY;
}
}
void ScaleFrame::apply(float percent)
{
if (_tween && percent != 0 || (_betweenScaleX != 0 || _betweenScaleY != 0))
{
float scaleX = _scaleX + _betweenScaleX * percent;
float scaleY = _scaleY + _betweenScaleY * percent;
_node->setScaleX(scaleX);
_node->setScaleY(scaleY);
}
}
Frame* ScaleFrame::clone()
{
ScaleFrame* frame = ScaleFrame::create();
frame->setScaleX(_scaleX);
frame->setScaleY(_scaleY);
frame->cloneProperty(this);
return frame;
}
// AnchorPointFrame
AnchorPointFrame* AnchorPointFrame::create()
{
AnchorPointFrame* frame = new AnchorPointFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
AnchorPointFrame::AnchorPointFrame()
: _anchorPoint(0.5f,0.5f)
{
}
void AnchorPointFrame::onEnter(Frame *nextFrame)
{
_node->setAnchorPoint(_anchorPoint);
}
Frame* AnchorPointFrame::clone()
{
AnchorPointFrame* frame = AnchorPointFrame::create();
frame->setAnchorPoint(_anchorPoint);
frame->cloneProperty(this);
return frame;
}
// InnerActionFrame
InnerActionFrame* InnerActionFrame::create()
{
InnerActionFrame* frame = new InnerActionFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
InnerActionFrame::InnerActionFrame()
: _innerActionType(LoopAction)
, _startFrameIndex(0)
{
}
void InnerActionFrame::onEnter(Frame *nextFrame)
{
}
Frame* InnerActionFrame::clone()
{
InnerActionFrame* frame = InnerActionFrame::create();
frame->setInnerActionType(_innerActionType);
frame->setStartFrameIndex(_startFrameIndex);
frame->cloneProperty(this);
return frame;
}
// ColorFrame
ColorFrame* ColorFrame::create()
{
ColorFrame* frame = new ColorFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
ColorFrame::ColorFrame()
: _alpha(255)
, _color(Color3B(255, 255, 255))
{
}
void ColorFrame::onEnter(Frame *nextFrame)
{
_node->setOpacity(_alpha);
_node->setColor(_color);
if(_tween)
{
_betweenAlpha = static_cast<ColorFrame*>(nextFrame)->_alpha - _alpha;
const Color3B& color = static_cast<ColorFrame*>(nextFrame)->_color;
_betweenRed = color.r - _color.r;
_betweenGreen = color.g - _color.g;
_betweenBlue = color.b - _color.b;
}
_node->setCascadeColorEnabled(true);
_node->setCascadeOpacityEnabled(true);
}
void ColorFrame::apply(float percent)
{
if (_tween && percent != 0 || (_betweenAlpha !=0 || _betweenRed != 0 || _betweenGreen != 0 || _betweenBlue != 0))
{
GLubyte alpha = _alpha + _betweenAlpha * percent;
Color3B color;
color.r = _color.r+ _betweenRed * percent;
color.g = _color.g+ _betweenGreen * percent;
color.b = _color.b+ _betweenBlue * percent;
_node->setOpacity(alpha);
_node->setColor(color);
}
}
Frame* ColorFrame::clone()
{
ColorFrame* frame = ColorFrame::create();
frame->setAlpha(_alpha);
frame->setColor(_color);
frame->cloneProperty(this);
return frame;
}
// EventFrame
EventFrame* EventFrame::create()
{
EventFrame* frame = new EventFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
EventFrame::EventFrame()
: _event("")
{
}
void EventFrame::onEnter(Frame *nextFrame)
{
emitEvent();
}
Frame* EventFrame::clone()
{
EventFrame* frame = EventFrame::create();
frame->setEvent(_event);
frame->cloneProperty(this);
return frame;
}
// ZOrderFrame
ZOrderFrame* ZOrderFrame::create()
{
ZOrderFrame* frame = new ZOrderFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
}
ZOrderFrame::ZOrderFrame()
: _zorder(0)
{
}
void ZOrderFrame::onEnter(Frame *nextFrame)
{
if(_node)
_node->setZOrder(_zorder);
}
Frame* ZOrderFrame::clone()
{
ZOrderFrame* frame = ZOrderFrame::create();
frame->setZOrder(_zorder);
frame->cloneProperty(this);
return frame;
}
NS_TIMELINE_END

View File

@ -0,0 +1,330 @@
/****************************************************************************
Copyright (c) 2013 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 __CCFRAME_H__
#define __CCFRAME_H__
#include "cocos2d.h"
#include "CCTimelineMacro.h"
NS_TIMELINE_BEGIN
class Timeline;
class Frame : public cocos2d::Ref
{
public:
virtual void setFrameIndex(unsigned int frameIndex) { _frameIndex = frameIndex; }
virtual unsigned int getFrameIndex() const { return _frameIndex; }
virtual void setTimeline(Timeline* timeline) { _timeline = timeline; }
virtual Timeline* getTimeline() const { return _timeline; }
virtual void setNode(cocos2d::Node* node) { _node = node; }
virtual cocos2d::Node* getNode() const { return _node; }
virtual void setTween(bool tween) { _tween = tween; }
virtual bool isTween() const { return _tween; }
virtual void onEnter(Frame *nextFrame) = 0;
virtual void apply(float percent) {}
virtual Frame* clone() = 0;
protected:
Frame();
virtual ~Frame();
virtual void emitEvent();
virtual void cloneProperty(Frame* frame);
protected:
unsigned int _frameIndex;
bool _tween;
Timeline* _timeline;
cocos2d::Node* _node;
};
class VisibleFrame : public Frame
{
public:
static VisibleFrame* create();
VisibleFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setVisible(bool visible) { _visible = visible;}
inline bool isVisible() const { return _visible; }
protected:
bool _visible;
};
class TextureFrame : public Frame
{
public:
static TextureFrame* create();
TextureFrame();
virtual void setNode(cocos2d::Node* node);
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setTextureName(std::string textureName) { _textureName = textureName;}
inline std::string getTextureName() const { return _textureName; }
protected:
cocos2d::Sprite* _sprite;
std::string _textureName;
};
class RotationFrame : public Frame
{
public:
static RotationFrame* create();
RotationFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setRotation(float rotation) { _rotation = rotation; }
inline float getRotation() const { return _rotation; }
protected:
float _rotation;
float _betwennRotation;
};
class SkewFrame : public Frame
{
public:
static SkewFrame* create();
SkewFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setSkewX(float skewx) { _skewX = skewx; }
inline float getSkewX() const { return _skewX; }
inline void setSkewY(float skewy) { _skewY = skewy; }
inline float getSkewY() const { return _skewY; }
protected:
float _skewX;
float _skewY;
float _betweenSkewX;
float _betweenSkewY;
};
class RotationSkewFrame : public SkewFrame
{
public:
static RotationSkewFrame* create();
RotationSkewFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
};
class PositionFrame : public Frame
{
public:
static PositionFrame* create();
PositionFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setPosition(const cocos2d::Point& position) { _position = position; }
inline cocos2d::Point getPosition() const { return _position; }
inline void setX(float x) { _position.x = x; }
inline void setY(float y) { _position.y = y; }
inline float getX() const { return _position.x; }
inline float getY() const { return _position.y; }
protected:
cocos2d::Point _position;
float _betweenX;
float _betweenY;
};
class ScaleFrame : public Frame
{
public:
static ScaleFrame* create();
ScaleFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setScale(float scale) { _scaleX = scale; _scaleY = scale; }
inline void setScaleX(float scaleX) { _scaleX = scaleX; }
inline float getScaleX() const { return _scaleX; }
inline void setScaleY(float scaleY) { _scaleY = scaleY;}
inline float getScaleY() const { return _scaleY; }
protected:
float _scaleX;
float _scaleY;
float _betweenScaleX;
float _betweenScaleY;
};
class AnchorPointFrame : public Frame
{
public:
static AnchorPointFrame* create();
AnchorPointFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setAnchorPoint(const cocos2d::Point& point) { _anchorPoint = point; }
inline cocos2d::Point getAnchorPoint() const { return _anchorPoint; }
protected:
cocos2d::Point _anchorPoint;
};
enum InnerActionType
{
LoopAction,
NoLoopAction,
SingleFrame
};
class InnerActionFrame : public Frame
{
public:
static InnerActionFrame* create();
InnerActionFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setInnerActionType(InnerActionType type) { _innerActionType = type; }
inline InnerActionType getInnerActionType() const { return _innerActionType; }
inline void setStartFrameIndex(int frameIndex) { _startFrameIndex = frameIndex; }
inline int getStartFrameIndex() const { return _startFrameIndex; }
protected:
InnerActionType _innerActionType;
int _startFrameIndex;
};
class ColorFrame : public Frame
{
public:
static ColorFrame* create();
ColorFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual void apply(float percent) override;
virtual Frame* clone() override;
inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
inline GLubyte getAlpha() const { return _alpha; }
inline void setColor(const cocos2d::Color3B& color) { _color = color; }
inline cocos2d::Color3B getColor() const { return _color; }
protected:
GLubyte _alpha;
cocos2d::Color3B _color;
int _betweenAlpha;
int _betweenRed;
int _betweenGreen;
int _betweenBlue;
};
class EventFrame : public Frame
{
public:
static EventFrame* create();
EventFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setEvent(std::string event) { _event = event;}
inline std::string getEvent() const { return _event; }
protected:
std::string _event;
};
class ZOrderFrame : public Frame
{
public:
static ZOrderFrame* create();
ZOrderFrame();
virtual void onEnter(Frame *nextFrame) override;
virtual Frame* clone() override;
inline void setZOrder(int zorder) { _zorder = zorder;}
inline int getZOrder() const { return _zorder; }
protected:
int _zorder;
};
NS_TIMELINE_END
#endif /*__CCFRAME_H__*/

View File

@ -0,0 +1,457 @@
/****************************************************************************
Copyright (c) 2013 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.
****************************************************************************/
#include "CCNodeReader.h"
#include "CCActionTimelineCache.h"
#include "CCActionTimeline.h"
#include "../CCSGUIReader.h"
using namespace cocos2d;
using namespace ui;
namespace cocostudio {
namespace timeline{
static const char* ClassName_Node = "Node";
static const char* ClassName_SubGraph = "SubGraph";
static const char* ClassName_Sprite = "Sprite";
static const char* ClassName_Particle = "Particle";
static const char* ClassName_Panel = "Panel";
static const char* ClassName_Button = "Button";
static const char* ClassName_CheckBox = "CheckBox";
static const char* ClassName_ImageView = "ImageView";
static const char* ClassName_TextAtlas = "TextAtlas";
static const char* ClassName_TextBMFont = "TextBMFont";
static const char* ClassName_Text = "Text";
static const char* ClassName_LoadingBar = "LoadingBar";
static const char* ClassName_TextField = "TextField";
static const char* ClassName_Slider = "Slider";
static const char* ClassName_Layout = "Layout";
static const char* ClassName_ScrollView = "ScrollView";
static const char* ClassName_ListView = "ListView";
static const char* ClassName_PageView = "PageView";
static const char* ClassName_Widget = "Widget";
static const char* ClassName_Label = "Label";
static const char* NODE = "nodeTree";
static const char* CHILDREN = "children";
static const char* CLASSNAME = "classname";
static const char* FILE_PATH = "fileName";
static const char* PLIST_FILE = "plistFile";
static const char* TAG = "tag";
static const char* ACTION_TAG = "actionTag";
static const char* OPTIONS = "options";
static const char* WIDTH = "width";
static const char* HEIGHT = "height";
static const char* X = "x";
static const char* Y = "y";
static const char* SCALE_X = "scaleX";
static const char* SCALE_Y = "scaleY";
static const char* SKEW_X = "skewX";
static const char* SKEW_Y = "skewY";
static const char* ROTATION = "rotation";
static const char* ROTATION_SKEW_X = "rotationSkewX";
static const char* ROTATION_SKEW_Y = "rotationSkewY";
static const char* ANCHOR_X = "anchorPointX";
static const char* ANCHOR_Y = "anchorPointY";
static const char* ALPHA = "opacity";
static const char* RED = "colorR";
static const char* GREEN = "colorG";
static const char* BLUE = "colorB";
static const char* ZORDER = "ZOrder";
static const char* PARTICLE_NUM = "particleNum";
static const char* FLIPX = "flipX";
static const char* FLIPY = "flipY";
static const char* VISIBLE = "visible";
static const char* TEXTURES = "textures";
static const char* TEXTURES_PNG = "texturesPng";
// NodeReader
static NodeReader* _sharedNodeReader = nullptr;
NodeReader* NodeReader::getInstance()
{
if (! _sharedNodeReader)
{
_sharedNodeReader = new NodeReader();
_sharedNodeReader->init();
}
return _sharedNodeReader;
}
void NodeReader::destroyInstance()
{
CC_SAFE_DELETE(_sharedNodeReader);
}
NodeReader::NodeReader()
: _recordJsonPath(true)
, _jsonPath("")
{
}
void NodeReader::purge()
{
}
void NodeReader::init()
{
using namespace std::placeholders;
_funcs.insert(Pair(ClassName_Node, std::bind(&NodeReader::loadSimpleNode, this, _1)));
_funcs.insert(Pair(ClassName_SubGraph, std::bind(&NodeReader::loadSubGraph, this, _1)));
_funcs.insert(Pair(ClassName_Sprite, std::bind(&NodeReader::loadSprite, this, _1)));
_funcs.insert(Pair(ClassName_Particle, std::bind(&NodeReader::loadParticle, this, _1)));
_funcs.insert(Pair(ClassName_Panel, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_Button, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_CheckBox, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_ImageView, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_TextAtlas, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_TextBMFont,std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_Text, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_LoadingBar,std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_TextField, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_Slider, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_Layout, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_ScrollView,std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_ListView, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_PageView, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_Widget, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_Label, std::bind(&NodeReader::loadWidget, this, _1)));
_guiReader = new WidgetPropertiesReader0300();
}
Node* NodeReader::createNode(const std::string& filename)
{
if(_recordJsonPath)
{
std::string jsonPath = filename.substr(0, filename.find_last_of('/') + 1);
GUIReader::getInstance()->setFilePath(jsonPath);
_jsonPath = jsonPath;
}
else
{
GUIReader::getInstance()->setFilePath("");
_jsonPath = "";
}
Node* node = loadNodeWithFile(filename);
return node;
}
Node* NodeReader::loadNodeWithFile(const std::string& fileName)
{
// Read content from file
std::string contentStr = FileUtils::getInstance()->getStringFromFile(fileName);
Node* node = loadNodeWithContent(contentStr);
// Load animation data from file
ActionTimelineCache::getInstance()->loadAnimationActionWithContent(fileName, contentStr);
return node;
}
Node* NodeReader::loadNodeWithContent(const std::string& content)
{
rapidjson::Document doc;
doc.Parse<0>(content.c_str());
if (doc.HasParseError())
{
CCLOG("GetParseError %s\n", doc.GetParseError());
}
// decode plist
int length = DICTOOL->getArrayCount_json(doc, TEXTURES);
for(int i=0; i<length; i++)
{
std::string plist = DICTOOL->getStringValueFromArray_json(doc, TEXTURES, i);
std::string png = DICTOOL->getStringValueFromArray_json(doc, TEXTURES_PNG, i);
plist = _jsonPath + plist;
png = _jsonPath + png;
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plist, png);
}
// decode node tree
const rapidjson::Value& subJson = DICTOOL->getSubDictionary_json(doc, NODE);
Node* root = loadNode(subJson);
root->release();
return root;
}
Node* NodeReader::loadNode(const rapidjson::Value& json)
{
Node* node = nullptr;
std::string nodeType = DICTOOL->getStringValue_json(json, CLASSNAME);
NodeCreateFunc func = _funcs.at(nodeType);
if (func != nullptr)
{
const rapidjson::Value& options = DICTOOL->getSubDictionary_json(json, OPTIONS);
node = func(options);
}
if(node)
{
int length = DICTOOL->getArrayCount_json(json, CHILDREN, 0);
for (int i = 0; i<length; i++)
{
const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, CHILDREN, i);
Node* child = loadNode(dic);
if (child)
{
node->addChild(child);
child->release();
}
}
}
else
{
CCLOG("Not supported NodeType: %s", nodeType.c_str());
}
return node;
}
void NodeReader::initNode(Node* node, const rapidjson::Value& json)
{
float width = DICTOOL->getFloatValue_json(json, WIDTH);
float height = DICTOOL->getFloatValue_json(json, HEIGHT);
float x = DICTOOL->getFloatValue_json(json, X);
float y = DICTOOL->getFloatValue_json(json, Y);
float scalex = DICTOOL->getFloatValue_json(json, SCALE_X, 1);
float scaley = DICTOOL->getFloatValue_json(json, SCALE_Y, 1);
float rotation = DICTOOL->getFloatValue_json(json, ROTATION);
float rotationSkewX = DICTOOL->getFloatValue_json(json, ROTATION_SKEW_X);
float rotationSkewY = DICTOOL->getFloatValue_json(json, ROTATION_SKEW_Y);
float skewx = DICTOOL->getFloatValue_json(json, SKEW_X);
float skewy = DICTOOL->getFloatValue_json(json, SKEW_Y);
float anchorx = DICTOOL->getFloatValue_json(json, ANCHOR_X, 0.5f);
float anchory = DICTOOL->getFloatValue_json(json, ANCHOR_Y, 0.5f);
GLubyte alpha = (GLubyte)DICTOOL->getIntValue_json(json, ALPHA, 255);
GLubyte red = (GLubyte)DICTOOL->getIntValue_json(json, RED, 255);
GLubyte green = (GLubyte)DICTOOL->getIntValue_json(json, GREEN, 255);
GLubyte blue = (GLubyte)DICTOOL->getIntValue_json(json, BLUE, 255);
int zorder = DICTOOL->getIntValue_json(json, ZORDER);
int tag = DICTOOL->getIntValue_json(json, TAG);
int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG);
bool visible = DICTOOL->getBooleanValue_json(json, VISIBLE);
if(x != 0 || y != 0)
node->setPosition(Point(x, y));
if(scalex != 1)
node->setScaleX(scalex);
if(scaley != 1)
node->setScaleY(scaley);
if (rotation != 0)
node->setRotation(rotation);
if(rotationSkewX != 0)
node->setRotationX(rotationSkewX);
if(rotationSkewY != 0)
node->setRotationY(rotationSkewY);
if(skewx != 0)
node->setSkewX(skewx);
if(skewy != 0)
node->setSkewY(skewy);
if(anchorx != 0.5f || anchory != 0.5f)
node->setAnchorPoint(Point(anchorx, anchory));
if(width != 0 || height != 0)
node->setContentSize(Size(width, height));
if(zorder != 0)
node->setZOrder(zorder);
if(visible != true)
node->setVisible(visible);
if(alpha != 255)
{
node->setOpacity(alpha);
node->setCascadeOpacityEnabled(true);
}
if(red != 255 || green != 255 || blue != 255)
{
node->setColor(Color3B(red, green, blue));
node->setCascadeColorEnabled(true);
}
node->setTag(tag);
node->setUserObject(ActionTimelineData::create(actionTag));
}
Node* NodeReader::loadSimpleNode(const rapidjson::Value& json)
{
Node* node = Node::create();
node->retain();
initNode(node, json);
return node;
}
Node* NodeReader::loadSubGraph(const rapidjson::Value& json)
{
const char* filePath = DICTOOL->getStringValue_json(json, FILE_PATH);
Node* node = nullptr;
if (filePath && strcmp("", filePath) != 0)
{
node = createNode(filePath);
}
else
{
node = Node::create();
}
node->retain();
initNode(node, json);
return node;
}
Node* NodeReader::loadSprite(const rapidjson::Value& json)
{
const char* filePath = DICTOOL->getStringValue_json(json, FILE_PATH);
Sprite *sprite = nullptr;
if(filePath != nullptr)
{
std::string path = filePath;
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(path);
if(!spriteFrame)
{
path = _jsonPath + path;
sprite = Sprite::create(path);
}
else
{
sprite = Sprite::createWithSpriteFrame(spriteFrame);
}
if(!sprite)
{
sprite = CCSprite::create();
CCLOG("filePath is empty. Create a sprite with no texture");
}
}
else
{
sprite = Sprite::create();
}
sprite->retain();
initNode(sprite, json);
bool flipX = DICTOOL->getBooleanValue_json(json, FLIPX);
bool flipY = DICTOOL->getBooleanValue_json(json, FLIPY);
if(flipX != false)
sprite->setFlipX(flipX);
if(flipY != false)
sprite->setFlipY(flipY);
return sprite;
}
Node* NodeReader::loadParticle(const rapidjson::Value& json)
{
const char* filePath = DICTOOL->getStringValue_json(json, PLIST_FILE);
int num = DICTOOL->getIntValue_json(json, PARTICLE_NUM);
ParticleSystemQuad* particle = ParticleSystemQuad::create(filePath);
particle->setTotalParticles(num);
particle->retain();
initNode(particle, json);
return particle;
}
Node* NodeReader::loadWidget(const rapidjson::Value& json)
{
const char* str = DICTOOL->getStringValue_json(json, CLASSNAME);
if(str == nullptr)
return nullptr;
std::string classname = str;
if (classname == "Panel")
{
classname = "Layout";
}
else if (classname == "TextArea")
{
classname = "Text";
}
else if (classname == "TextButton")
{
classname = "Button";
}
else if (classname == "Label")
{
classname = "Text";
}
else if (classname == "LabelAtlas")
{
classname = "TextAtlas";
}
else if (classname == "LabelBMFont")
{
classname = "TextBMFont";
}
std::string readerName = classname;
readerName.append("Reader");
Widget* widget = dynamic_cast<Widget*>(ObjectFactory::getInstance()->createObject(classname));
widget->retain();
WidgetReaderProtocol* reader = dynamic_cast<WidgetReaderProtocol*>(ObjectFactory::getInstance()->createObject(readerName));
_guiReader->setPropsForAllWidgetFromJsonDictionary(reader, widget, json);
int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG);
widget->setUserObject(ActionTimelineData::create(actionTag));
return widget;
}
}
}

View File

@ -0,0 +1,91 @@
/****************************************************************************
Copyright (c) 2013 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 __CC_NODE_CACHE_H__
#define __CC_NODE_CACHE_H__
#include "cocostudio/DictionaryHelper.h"
#include "cocos2d.h"
namespace cocostudio {
class WidgetPropertiesReader0300;
namespace timeline{
class NodeReader
{
public:
static NodeReader* getInstance();
static void destroyInstance();
NodeReader();
void purge();
void init();
cocos2d::Node* createNode(const std::string& filename);
cocos2d::Node* loadNodeWithFile(const std::string& fileName);
cocos2d::Node* loadNodeWithContent(const std::string& content);
void setRecordJsonPath(bool record) { _recordJsonPath = record; }
bool isRecordJsonPath() const { return _recordJsonPath; }
void setJsonPath(std::string jsonPath) { _jsonPath = jsonPath; }
std::string getJsonPath() const { return _jsonPath; }
protected:
cocos2d::Node* loadNode(const rapidjson::Value& json);
void locateNodeWithMulresPosition(cocos2d::Node* node, const rapidjson::Value& json);
void initNode(cocos2d::Node* node, const rapidjson::Value& json);
// load nodes
cocos2d::Node* loadSimpleNode(const rapidjson::Value& json);
cocos2d::Node* loadSubGraph (const rapidjson::Value& json);
cocos2d::Node* loadSprite (const rapidjson::Value& json);
cocos2d::Node* loadParticle (const rapidjson::Value& json);
// load gui
cocos2d::Node* loadWidget(const rapidjson::Value& json);
typedef std::function<cocos2d::Node*(const rapidjson::Value& json)> NodeCreateFunc;
typedef std::pair<std::string, NodeCreateFunc> Pair;
std::unordered_map<std::string, NodeCreateFunc> _funcs;
WidgetPropertiesReader0300* _guiReader;
bool _recordJsonPath;
std::string _jsonPath;
};
}
}
#endif /*__CC_NODE_CACHE_H__*/

View File

@ -0,0 +1,249 @@
/****************************************************************************
Copyright (c) 2013 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.
****************************************************************************/
#include "CCTimeLine.h"
#include "CCActionTimeline.h"
USING_NS_CC;
NS_TIMELINE_BEGIN
Timeline* Timeline::create()
{
Timeline* object = new Timeline();
if (object)
{
object->autorelease();
return object;
}
CC_SAFE_DELETE(object);
return nullptr;
}
Timeline::Timeline()
: _currentKeyFrame(nullptr)
, _currentKeyFrameIndex(0)
, _fromIndex(0)
, _toIndex(0)
, _betweenDuration(0)
, _actionTag(0)
, _ActionTimeline(nullptr)
, _node(nullptr)
{
}
Timeline::~Timeline()
{
}
void Timeline::gotoFrame(int frameIndex)
{
if(_frames.size() == 0)
return;
binarySearchKeyFrame(frameIndex);
apply(frameIndex);
}
void Timeline::stepToFrame(int frameIndex)
{
if(_frames.size() == 0)
return;
updateCurrentKeyFrame(frameIndex);
apply(frameIndex);
}
Timeline* Timeline::clone()
{
Timeline* timeline = Timeline::create();
timeline->_actionTag = _actionTag;
for (auto frame : _frames)
{
Frame* newFrame = frame->clone();
timeline->addFrame(newFrame);
}
return timeline;
}
void Timeline::addFrame(Frame* frame)
{
_frames.pushBack(frame);
frame->setTimeline(this);
}
void Timeline::insertFrame(Frame* frame, int index)
{
_frames.insert(index, frame);
frame->setTimeline(this);
}
void Timeline::removeFrame(Frame* frame)
{
_frames.eraseObject(frame);
frame->setTimeline(NULL);
}
void Timeline::setNode(Node* node)
{
for (auto frame : _frames)
{
frame->setNode(node);
}
}
Node* Timeline::getNode() const
{
return _node;
}
void Timeline::apply(int frameIndex)
{
if (_currentKeyFrame)
{
float currentPercent = _betweenDuration == 0 ? 0 : (frameIndex - _currentKeyFrameIndex) / (float)_betweenDuration;
_currentKeyFrame->apply(currentPercent);
}
}
void Timeline::binarySearchKeyFrame(int frameIndex)
{
Frame *from = NULL;
Frame *to = NULL;
long length = _frames.size();
bool needEnterFrame = false;
do
{
if (frameIndex < _frames.at(0)->getFrameIndex())
{
if(_currentKeyFrameIndex >= _frames.at(0)->getFrameIndex())
needEnterFrame = true;
from = to = _frames.at(0);
_currentKeyFrameIndex = 0;
_betweenDuration = _frames.at(0)->getFrameIndex();
break;
}
else if(frameIndex >= _frames.at(length - 1)->getFrameIndex())
{
from = to = _frames.at(length - 1);
_currentKeyFrameIndex = _frames.at(length - 1)->getFrameIndex();
_betweenDuration = 0;
break;
}
int target = -1;
int low=0,high=length-1,mid;
while(low<=high){
mid=(low+high)/2;
if(frameIndex >= _frames.at(mid)->getFrameIndex() && frameIndex < _frames.at(mid+1)->getFrameIndex())
{
target = mid;
break;
}
if(_frames.at(mid)->getFrameIndex()>frameIndex)
high=mid-1;
else
low=mid+1;
}
from = _frames.at(target);
to = _frames.at(target+1);
if(target == 0 && _currentKeyFrameIndex<from->getFrameIndex())
needEnterFrame = true;
_currentKeyFrameIndex = from->getFrameIndex();
_betweenDuration = to->getFrameIndex() - from->getFrameIndex();
} while (0);
if(needEnterFrame || _currentKeyFrame != from)
{
_currentKeyFrame = from;
_currentKeyFrame->onEnter(to);
}
}
void Timeline::updateCurrentKeyFrame(int frameIndex)
{
//! If play to current frame's front or back, then find current frame again
if (frameIndex < _currentKeyFrameIndex || frameIndex >= _currentKeyFrameIndex + _betweenDuration)
{
Frame *from = nullptr;
Frame *to = nullptr;
do
{
long length = _frames.size();
if (frameIndex < _frames.at(0)->getFrameIndex())
{
from = to = _frames.at(0);
_currentKeyFrameIndex = 0;
_betweenDuration = _frames.at(0)->getFrameIndex();
break;
}
else if(frameIndex >= _frames.at(length - 1)->getFrameIndex())
{
from = to = _frames.at(length - 1);
_currentKeyFrameIndex = _frames.at(length - 1)->getFrameIndex();
_betweenDuration = 0;
break;
}
do
{
_fromIndex = _toIndex;
from = _frames.at(_fromIndex);
_currentKeyFrameIndex = from->getFrameIndex();
_toIndex = _fromIndex + 1;
if (_toIndex >= length)
{
_toIndex = 0;
}
to = _frames.at(_toIndex);
if (frameIndex == from->getFrameIndex())
{
break;
}
}
while (frameIndex < from->getFrameIndex() || frameIndex >= to->getFrameIndex());
_betweenDuration = to->getFrameIndex() - from->getFrameIndex();
} while (0);
_currentKeyFrame = from;
_currentKeyFrame->onEnter(to);
}
}
NS_TIMELINE_END

View File

@ -0,0 +1,85 @@
/****************************************************************************
Copyright (c) 2013 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 __CCTIMELINE_H__
#define __CCTIMELINE_H__
#include "CCFrame.h"
#include "CCTimelineMacro.h"
NS_TIMELINE_BEGIN
class ActionTimeline;
class Timeline : public cocos2d::Ref
{
public:
static Timeline* create();
Timeline();
virtual ~Timeline();
virtual void gotoFrame(int frameIndex);
virtual void stepToFrame(int frameIndex);
virtual const cocos2d::Vector<Frame*>& getFrames() const { return _frames; }
virtual void addFrame(Frame* frame);
virtual void insertFrame(Frame* frame, int index);
virtual void removeFrame(Frame* frame);
virtual void setActionTag(int tag) { _actionTag = tag; }
virtual int getActionTag() const { return _actionTag; }
virtual void setNode(cocos2d::Node* node);
virtual cocos2d::Node* getNode() const;
virtual void setActionTimeline(ActionTimeline* action) { _ActionTimeline = action; }
virtual ActionTimeline* getActionTimeline() const { return _ActionTimeline; }
virtual Timeline* clone();
protected:
virtual void apply(int frameIndex);
virtual void binarySearchKeyFrame (int frameIndex);
virtual void updateCurrentKeyFrame(int frameIndex);
cocos2d::Vector<Frame*> _frames;
Frame* _currentKeyFrame;
int _currentKeyFrameIndex;
int _fromIndex;
int _toIndex;
int _betweenDuration;
int _actionTag;
ActionTimeline* _ActionTimeline;
cocos2d::Node* _node;
};
NS_TIMELINE_END
#endif /*__CCTIMELINE_H__*/

View File

@ -0,0 +1,38 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies
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 __CC_TIMELINE_MACROS_H__
#define __CC_TIMELINE_MACROS_H__
#ifdef __cplusplus
#define NS_TIMELINE_BEGIN namespace cocostudio { namespace timeline{
#define NS_TIMELINE_END }}
#define USING_NS_TIMELINE using namespace cocostudio::timeline;
#else
#define NS_TIMELINE_BEGIN
#define NS_TIMELINE_END
#define USING_NS_TIMELINE
#endif
#endif

View File

@ -53,6 +53,11 @@ WidgetReader/TextAtlasReader/TextAtlasReader.cpp \
WidgetReader/TextBMFontReader/TextBMFontReader.cpp \
WidgetReader/TextFieldReader/TextFieldReader.cpp \
WidgetReader/TextReader/TextReader.cpp \
ActionTimeline/CCNodeReader.cpp \
ActionTimeline/CCActionTimelineCache.cpp \
ActionTimeline/CCFrame.cpp \
ActionTimeline/CCTimeline.cpp \
ActionTimeline/CCActionTimeline.cpp \
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \
$(LOCAL_PATH)/../../../external

View File

@ -494,6 +494,8 @@ Rect Armature::getBoundingBox() const
if (Bone *bone = dynamic_cast<Bone *>(object))
{
Rect r = bone->getDisplayManager()->getBoundingBox();
if (r.equals(Rect::ZERO))
continue;
if(first)
{

View File

@ -1185,8 +1185,22 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, D
void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, DataInfo *dataInfo)
{
rapidjson::Document json;
rapidjson::StringStream stream(fileContent.c_str());
json.Parse<0>(fileContent.c_str());
if (fileContent.size() >= 3) {
// Skip BOM if exists
const unsigned char* c = (const unsigned char *)fileContent.c_str();
unsigned bom = c[0] | (c[1] << 8) | (c[2] << 16);
if (bom == 0xBFBBEF) // UTF8 BOM
{
stream.Take();
stream.Take();
stream.Take();
}
}
json.ParseStream<0>(stream);
if (json.HasParseError()) {
CCLOG("GetParseError %s\n",json.GetParseError());
}

View File

@ -181,7 +181,8 @@ Widget* GUIReader::widgetFromJsonFile(const char *fileName)
{
std::string jsonpath;
rapidjson::Document jsonDict;
jsonpath = CCFileUtils::getInstance()->fullPathForFilename(fileName);
jsonpath = fileName;
// jsonpath = CCFileUtils::getInstance()->fullPathForFilename(fileName);
size_t pos = jsonpath.find_last_of('/');
m_strFilePath = jsonpath.substr(0,pos+1);
std::string contentStr = FileUtils::getInstance()->getStringFromFile(jsonpath);

View File

@ -59,13 +59,14 @@ public:
*/
const cocos2d::Size getFileDesignSize(const char* fileName) const;
const std::string& getFilePath() const { return m_strFilePath; };
void setFilePath(const std::string& strFilePath) { m_strFilePath = strFilePath; }
const std::string& getFilePath() const { return m_strFilePath; }
void registerTypeAndCallBack(const std::string& classType,
cocos2d::ObjectFactory::Instance ins,
Ref* object,
SEL_ParseEvent callBack);
protected:
GUIReader();
~GUIReader();

View File

@ -47,6 +47,11 @@ set(CS_SRC
WidgetReader/TextBMFontReader/TextBMFontReader.cpp
WidgetReader/TextFieldReader/TextFieldReader.cpp
WidgetReader/TextReader/TextReader.cpp
ActionTimeline/CCActionTimeline.cpp
ActionTimeline/CCActionTimelineCache.cpp
ActionTimeline/CCFrame.cpp
ActionTimeline/CCNodeReader.cpp
ActionTimeline/CCTimeLine.cpp
)
include_directories(

View File

@ -58,5 +58,10 @@ THE SOFTWARE.
#include "cocostudio/CCSGUIReader.h"
#include "cocostudio/CCSSceneReader.h"
#include "cocostudio/TriggerBase.h"
#include "cocostudio/ActionTimeline/CCNodeReader.h"
#include "cocostudio/ActionTimeline/CCActionTimelineCache.h"
#include "cocostudio/ActionTimeline/CCFrame.h"
#include "cocostudio/ActionTimeline/CCTimeLine.h"
#include "cocostudio/ActionTimeline/CCActionTimeline.h"
#endif

View File

@ -11,6 +11,11 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\ActionTimeline\CCActionTimeline.cpp" />
<ClCompile Include="..\ActionTimeline\CCFrame.cpp" />
<ClCompile Include="..\ActionTimeline\CCNodeReader.cpp" />
<ClCompile Include="..\ActionTimeline\CCActionTimelineCache.cpp" />
<ClCompile Include="..\ActionTimeline\CCTimeLine.cpp" />
<ClCompile Include="..\CCActionFrame.cpp" />
<ClCompile Include="..\CCActionFrameEasing.cpp" />
<ClCompile Include="..\CCActionManagerEx.cpp" />
@ -71,6 +76,12 @@
<ClInclude Include="..\..\..\..\external\json\reader.h" />
<ClInclude Include="..\..\..\..\external\json\stringbuffer.h" />
<ClInclude Include="..\..\..\..\external\json\writer.h" />
<ClInclude Include="..\ActionTimeline\CCActionTimeline.h" />
<ClInclude Include="..\ActionTimeline\CCFrame.h" />
<ClInclude Include="..\ActionTimeline\CCNodeReader.h" />
<ClInclude Include="..\ActionTimeline\CCActionTimelineCache.h" />
<ClInclude Include="..\ActionTimeline\CCTimeLine.h" />
<ClInclude Include="..\ActionTimeline\CCTimelineMacro.h" />
<ClInclude Include="..\CCActionFrame.h" />
<ClInclude Include="..\CCActionFrameEasing.h" />
<ClInclude Include="..\CCActionManagerEx.h" />
@ -103,7 +114,6 @@
<ClInclude Include="..\CCTween.h" />
<ClInclude Include="..\CCUtilMath.h" />
<ClInclude Include="..\DictionaryHelper.h" />
<ClInclude Include="..\ObjectFactory.h" />
<ClInclude Include="..\TriggerBase.h" />
<ClInclude Include="..\TriggerMng.h" />
<ClInclude Include="..\TriggerObj.h" />

View File

@ -82,6 +82,9 @@
<Filter Include="reader\WidgetReader\TextReader">
<UniqueIdentifier>{bc251d28-036e-4272-852b-bd25fd110b33}</UniqueIdentifier>
</Filter>
<Filter Include="TimelineAction">
<UniqueIdentifier>{2d371825-3c46-4901-850c-3bccf6b49efc}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\CCComAttribute.cpp">
@ -228,6 +231,21 @@
<ClCompile Include="..\WidgetReader\PageViewReader\PageViewReader.cpp">
<Filter>reader\WidgetReader\PageViewReader</Filter>
</ClCompile>
<ClCompile Include="..\ActionTimeline\CCNodeReader.cpp">
<Filter>TimelineAction</Filter>
</ClCompile>
<ClCompile Include="..\ActionTimeline\CCActionTimelineCache.cpp">
<Filter>TimelineAction</Filter>
</ClCompile>
<ClCompile Include="..\ActionTimeline\CCActionTimeline.cpp">
<Filter>TimelineAction</Filter>
</ClCompile>
<ClCompile Include="..\ActionTimeline\CCFrame.cpp">
<Filter>TimelineAction</Filter>
</ClCompile>
<ClCompile Include="..\ActionTimeline\CCTimeLine.cpp">
<Filter>TimelineAction</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\CCComAttribute.h">
@ -353,9 +371,6 @@
<ClInclude Include="..\CCActionObject.h">
<Filter>action</Filter>
</ClInclude>
<ClInclude Include="..\ObjectFactory.h">
<Filter>trigger</Filter>
</ClInclude>
<ClInclude Include="..\TriggerBase.h">
<Filter>trigger</Filter>
</ClInclude>
@ -413,5 +428,23 @@
<ClInclude Include="..\WidgetReader\PageViewReader\PageViewReader.h">
<Filter>reader\WidgetReader\PageViewReader</Filter>
</ClInclude>
<ClInclude Include="..\ActionTimeline\CCNodeReader.h">
<Filter>TimelineAction</Filter>
</ClInclude>
<ClInclude Include="..\ActionTimeline\CCActionTimelineCache.h">
<Filter>TimelineAction</Filter>
</ClInclude>
<ClInclude Include="..\ActionTimeline\CCActionTimeline.h">
<Filter>TimelineAction</Filter>
</ClInclude>
<ClInclude Include="..\ActionTimeline\CCFrame.h">
<Filter>TimelineAction</Filter>
</ClInclude>
<ClInclude Include="..\ActionTimeline\CCTimeLine.h">
<Filter>TimelineAction</Filter>
</ClInclude>
<ClInclude Include="..\ActionTimeline\CCTimelineMacro.h">
<Filter>TimelineAction</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -24,14 +24,14 @@ set(COCOS_NETWORK_SRC
${PLATFORM_SRC}
)
IF ( WIN32 )
set(COCOS_NETWORK_LINK
IF (WIN32 AND NOT MINGW)
set(COCOS_NETWORK_LINK
libcurl_imp
${PLATFORM_LINK}
)
)
ELSE()
set(COCOS_NETWORK_LINK
set(COCOS_NETWORK_LINK
curl
${PLATFORM_LINK}
)
)
ENDIF()

View File

@ -512,6 +512,7 @@ static Data getData(const std::string& filename, bool forString)
Data ret;
unsigned char* buffer = nullptr;
ssize_t size = 0;
size_t readsize;
const char* mode = nullptr;
if (forString)
mode = "rt";
@ -538,11 +539,16 @@ static Data getData(const std::string& filename, bool forString)
buffer = (unsigned char*)malloc(sizeof(unsigned char) * size);
}
size = fread(buffer, sizeof(unsigned char), size, fp);
readsize = fread(buffer, sizeof(unsigned char), size, fp);
fclose(fp);
if (forString && readsize < size)
{
buffer[readsize] = '\0';
}
} while (0);
if (nullptr == buffer || 0 == size)
if (nullptr == buffer || 0 == readsize)
{
std::string msg = "Get data from file(";
msg.append(filename).append(") failed!");
@ -550,7 +556,7 @@ static Data getData(const std::string& filename, bool forString)
}
else
{
ret.fastSet(buffer, size);
ret.fastSet(buffer, readsize);
}
return ret;

View File

@ -265,7 +265,7 @@ void GLViewProtocol::handleTouchesBegin(int num, intptr_t ids[], float xs[], flo
touch->setTouchInfo(unusedIndex, (x - _viewPortRect.origin.x) / _scaleX,
(y - _viewPortRect.origin.y) / _scaleY);
CCLOGINFO("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y);
CCLOGINFO("x = %f y = %f", touch->getLocationInView().x, touch->getLocationInView().y);
g_touchIdReorderMap.insert(std::make_pair(id, unusedIndex));
touchEvent._touches.push_back(touch);

View File

@ -34,7 +34,7 @@ NS_CC_BEGIN
class GLProgramState;
class GLProgram;
class Uniform;
struct Uniform;
//it is a common mesh
class MeshCommand : public RenderCommand

View File

@ -0,0 +1,22 @@
--------------------------------
-- @module ActionTimelineData
-- @extend Ref
--------------------------------
-- @function [parent=#ActionTimelineData] setActionTag
-- @param self
-- @param #int int
--------------------------------
-- @function [parent=#ActionTimelineData] getActionTag
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#ActionTimelineData] create
-- @param self
-- @param #int int
-- @return timeline::ActionTimelineData#timeline::ActionTimelineData ret (return value: ccs.timeline::ActionTimelineData)
return nil

View File

@ -3,6 +3,11 @@
-- @module GUIReader
-- @extend Ref
--------------------------------
-- @function [parent=#GUIReader] setFilePath
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#GUIReader] widgetFromJsonFile
-- @param self

View File

@ -43,11 +43,6 @@
-- @param self
-- @return color4b_table#color4b_table ret (return value: color4b_table)
--------------------------------
-- @function [parent=#Label] getCommonLineHeight
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#Label] setWidth
-- @param self
@ -90,6 +85,11 @@
-- @param self
-- @return FontAtlas#FontAtlas ret (return value: cc.FontAtlas)
--------------------------------
-- @function [parent=#Label] setLineHeight
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#Label] setSystemFontSize
-- @param self
@ -120,6 +120,11 @@
-- @param #color4b_table color4b
-- @param #int int
--------------------------------
-- @function [parent=#Label] getAdditionalKerning
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- overload function: setCharMap(cc.Texture2D, int, int, int)
--
@ -155,6 +160,11 @@
-- @param self
-- @param #cc.TextVAlignment textvalignment
--------------------------------
-- @function [parent=#Label] getLineHeight
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#Label] getTTFConfig
-- @param self
@ -191,6 +201,11 @@
-- @param #int int
-- @return Sprite#Sprite ret (return value: cc.Sprite)
--------------------------------
-- @function [parent=#Label] setAdditionalKerning
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#Label] getSystemFontSize
-- @param self

View File

@ -18,4 +18,12 @@
-- @function [parent=#SkeletonAnimation] clearTrack
-- @param self
--------------------------------
-- @function [parent=#SkeletonAnimation] onAnimationStateEvent
-- @param self
-- @param #int int
-- @param #spEventType speventtype
-- @param #spEvent spevent
-- @param #int int
return nil

View File

@ -146,4 +146,9 @@
-- @field [parent=#ccs] SceneReader#SceneReader SceneReader preloaded module
--------------------------------------------------------
-- the ccs ActionTimelineData
-- @field [parent=#ccs] ActionTimelineData#ActionTimelineData ActionTimelineData preloaded module
return nil

View File

@ -32605,50 +32605,6 @@ int lua_cocos2dx_Label_getTextColor(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Label_getCommonLineHeight(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Label* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getCommonLineHeight'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
int ret = cobj->getCommonLineHeight();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCommonLineHeight",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getCommonLineHeight'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Label_setWidth(lua_State* tolua_S)
{
int argc = 0;
@ -33026,6 +32982,52 @@ int lua_cocos2dx_Label_getFontAtlas(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Label_setLineHeight(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Label* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setLineHeight'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0);
if(!ok)
return 0;
cobj->setLineHeight(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLineHeight",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setLineHeight'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Label_setSystemFontSize(lua_State* tolua_S)
{
int argc = 0;
@ -33308,6 +33310,50 @@ int lua_cocos2dx_Label_enableOutline(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Label_getAdditionalKerning(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Label* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getAdditionalKerning'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
double ret = cobj->getAdditionalKerning();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAdditionalKerning",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getAdditionalKerning'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Label_setCharMap(lua_State* tolua_S)
{
int argc = 0;
@ -33579,6 +33625,50 @@ int lua_cocos2dx_Label_setVerticalAlignment(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Label_getLineHeight(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Label* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getLineHeight'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
double ret = cobj->getLineHeight();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLineHeight",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getLineHeight'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Label_getTTFConfig(lua_State* tolua_S)
{
int argc = 0;
@ -33896,6 +33986,52 @@ int lua_cocos2dx_Label_getLetter(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Label_setAdditionalKerning(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Label* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setAdditionalKerning'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0);
if(!ok)
return 0;
cobj->setAdditionalKerning(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAdditionalKerning",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setAdditionalKerning'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Label_getSystemFontSize(lua_State* tolua_S)
{
int argc = 0;
@ -34435,7 +34571,6 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S)
tolua_function(tolua_S,"disableEffect",lua_cocos2dx_Label_disableEffect);
tolua_function(tolua_S,"setTTFConfig",lua_cocos2dx_Label_setTTFConfig);
tolua_function(tolua_S,"getTextColor",lua_cocos2dx_Label_getTextColor);
tolua_function(tolua_S,"getCommonLineHeight",lua_cocos2dx_Label_getCommonLineHeight);
tolua_function(tolua_S,"setWidth",lua_cocos2dx_Label_setWidth);
tolua_function(tolua_S,"getMaxLineWidth",lua_cocos2dx_Label_getMaxLineWidth);
tolua_function(tolua_S,"getHorizontalAlignment",lua_cocos2dx_Label_getHorizontalAlignment);
@ -34444,17 +34579,20 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S)
tolua_function(tolua_S,"setSystemFontName",lua_cocos2dx_Label_setSystemFontName);
tolua_function(tolua_S,"setBMFontFilePath",lua_cocos2dx_Label_setBMFontFilePath);
tolua_function(tolua_S,"getFontAtlas",lua_cocos2dx_Label_getFontAtlas);
tolua_function(tolua_S,"setLineHeight",lua_cocos2dx_Label_setLineHeight);
tolua_function(tolua_S,"setSystemFontSize",lua_cocos2dx_Label_setSystemFontSize);
tolua_function(tolua_S,"updateContent",lua_cocos2dx_Label_updateContent);
tolua_function(tolua_S,"getStringLength",lua_cocos2dx_Label_getStringLength);
tolua_function(tolua_S,"setLineBreakWithoutSpace",lua_cocos2dx_Label_setLineBreakWithoutSpace);
tolua_function(tolua_S,"getStringNumLines",lua_cocos2dx_Label_getStringNumLines);
tolua_function(tolua_S,"enableOutline",lua_cocos2dx_Label_enableOutline);
tolua_function(tolua_S,"getAdditionalKerning",lua_cocos2dx_Label_getAdditionalKerning);
tolua_function(tolua_S,"setCharMap",lua_cocos2dx_Label_setCharMap);
tolua_function(tolua_S,"getDimensions",lua_cocos2dx_Label_getDimensions);
tolua_function(tolua_S,"setMaxLineWidth",lua_cocos2dx_Label_setMaxLineWidth);
tolua_function(tolua_S,"getSystemFontName",lua_cocos2dx_Label_getSystemFontName);
tolua_function(tolua_S,"setVerticalAlignment",lua_cocos2dx_Label_setVerticalAlignment);
tolua_function(tolua_S,"getLineHeight",lua_cocos2dx_Label_getLineHeight);
tolua_function(tolua_S,"getTTFConfig",lua_cocos2dx_Label_getTTFConfig);
tolua_function(tolua_S,"getVerticalAlignment",lua_cocos2dx_Label_getVerticalAlignment);
tolua_function(tolua_S,"setTextColor",lua_cocos2dx_Label_setTextColor);
@ -34462,6 +34600,7 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S)
tolua_function(tolua_S,"getWidth",lua_cocos2dx_Label_getWidth);
tolua_function(tolua_S,"enableGlow",lua_cocos2dx_Label_enableGlow);
tolua_function(tolua_S,"getLetter",lua_cocos2dx_Label_getLetter);
tolua_function(tolua_S,"setAdditionalKerning",lua_cocos2dx_Label_setAdditionalKerning);
tolua_function(tolua_S,"getSystemFontSize",lua_cocos2dx_Label_getSystemFontSize);
tolua_function(tolua_S,"getTextAlignment",lua_cocos2dx_Label_getTextAlignment);
tolua_function(tolua_S,"getBMFontFilePath",lua_cocos2dx_Label_getBMFontFilePath);

View File

@ -1545,6 +1545,9 @@ int register_all_cocos2dx(lua_State* tolua_S);

View File

@ -494,6 +494,61 @@ int lua_cocos2dx_spine_SkeletonAnimation_clearTrack(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(lua_State* tolua_S)
{
int argc = 0;
spine::SkeletonAnimation* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (spine::SkeletonAnimation*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 4)
{
int arg0;
spEventType arg1;
spEvent* arg2;
int arg3;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1);
#pragma warning NO CONVERSION TO NATIVE FOR spEvent*;
ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3);
if(!ok)
return 0;
cobj->onAnimationStateEvent(arg0, arg1, arg2, arg3);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onAnimationStateEvent",argc, 4);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_spine_SkeletonAnimation_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (SkeletonAnimation)");
@ -509,6 +564,7 @@ int lua_register_cocos2dx_spine_SkeletonAnimation(lua_State* tolua_S)
tolua_function(tolua_S,"setMix",lua_cocos2dx_spine_SkeletonAnimation_setMix);
tolua_function(tolua_S,"clearTracks",lua_cocos2dx_spine_SkeletonAnimation_clearTracks);
tolua_function(tolua_S,"clearTrack",lua_cocos2dx_spine_SkeletonAnimation_clearTrack);
tolua_function(tolua_S,"onAnimationStateEvent",lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent);
tolua_endmodule(tolua_S);
std::string typeName = typeid(spine::SkeletonAnimation).name();
g_luaType[typeName] = "sp.SkeletonAnimation";

View File

@ -22,4 +22,5 @@ int register_all_cocos2dx_spine(lua_State* tolua_S);
#endif // __cocos2dx_spine_h__

View File

@ -12018,6 +12018,52 @@ int lua_register_cocos2dx_studio_ComRender(lua_State* tolua_S)
return 1;
}
int lua_cocos2dx_studio_GUIReader_setFilePath(lua_State* tolua_S)
{
int argc = 0;
cocostudio::GUIReader* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccs.GUIReader",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::GUIReader*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_GUIReader_setFilePath'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if(!ok)
return 0;
cobj->setFilePath(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFilePath",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_GUIReader_setFilePath'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_studio_GUIReader_widgetFromJsonFile(lua_State* tolua_S)
{
int argc = 0;
@ -12229,6 +12275,7 @@ int lua_register_cocos2dx_studio_GUIReader(lua_State* tolua_S)
tolua_cclass(tolua_S,"GUIReader","ccs.GUIReader","cc.Ref",nullptr);
tolua_beginmodule(tolua_S,"GUIReader");
tolua_function(tolua_S,"setFilePath",lua_cocos2dx_studio_GUIReader_setFilePath);
tolua_function(tolua_S,"widgetFromJsonFile",lua_cocos2dx_studio_GUIReader_widgetFromJsonFile);
tolua_function(tolua_S,"getFilePath",lua_cocos2dx_studio_GUIReader_getFilePath);
tolua_function(tolua_S,"getVersionInteger",lua_cocos2dx_studio_GUIReader_getVersionInteger);
@ -12560,6 +12607,151 @@ int lua_register_cocos2dx_studio_SceneReader(lua_State* tolua_S)
g_typeCast["SceneReader"] = "ccs.SceneReader";
return 1;
}
int lua_cocos2dx_studio_ActionTimelineData_setActionTag(lua_State* tolua_S)
{
int argc = 0;
cocostudio::timeline::ActionTimelineData* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccs.timeline::ActionTimelineData",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::timeline::ActionTimelineData*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionTimelineData_setActionTag'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
if(!ok)
return 0;
cobj->setActionTag(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setActionTag",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionTimelineData_setActionTag'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_studio_ActionTimelineData_getActionTag(lua_State* tolua_S)
{
int argc = 0;
cocostudio::timeline::ActionTimelineData* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccs.timeline::ActionTimelineData",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::timeline::ActionTimelineData*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionTimelineData_getActionTag'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
int ret = cobj->getActionTag();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getActionTag",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionTimelineData_getActionTag'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_studio_ActionTimelineData_create(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"ccs.timeline::ActionTimelineData",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
if(!ok)
return 0;
cocostudio::timeline::ActionTimelineData* ret = cocostudio::timeline::ActionTimelineData::create(arg0);
object_to_luaval<cocostudio::timeline::ActionTimelineData>(tolua_S, "ccs.timeline::ActionTimelineData",(cocostudio::timeline::ActionTimelineData*)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionTimelineData_create'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_studio_ActionTimelineData_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (ActionTimelineData)");
return 0;
}
int lua_register_cocos2dx_studio_ActionTimelineData(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"ccs.timeline::ActionTimelineData");
tolua_cclass(tolua_S,"ActionTimelineData","ccs.timeline::ActionTimelineData","cc.Ref",nullptr);
tolua_beginmodule(tolua_S,"ActionTimelineData");
tolua_function(tolua_S,"setActionTag",lua_cocos2dx_studio_ActionTimelineData_setActionTag);
tolua_function(tolua_S,"getActionTag",lua_cocos2dx_studio_ActionTimelineData_getActionTag);
tolua_function(tolua_S,"create", lua_cocos2dx_studio_ActionTimelineData_create);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocostudio::timeline::ActionTimelineData).name();
g_luaType[typeName] = "ccs.timeline::ActionTimelineData";
g_typeCast["ActionTimelineData"] = "ccs.timeline::ActionTimelineData";
return 1;
}
TOLUA_API int register_all_cocos2dx_studio(lua_State* tolua_S)
{
tolua_open(tolua_S);
@ -12571,6 +12763,7 @@ TOLUA_API int register_all_cocos2dx_studio(lua_State* tolua_S)
lua_register_cocos2dx_studio_ContourData(tolua_S);
lua_register_cocos2dx_studio_SceneReader(tolua_S);
lua_register_cocos2dx_studio_ComAudio(tolua_S);
lua_register_cocos2dx_studio_ActionTimelineData(tolua_S);
lua_register_cocos2dx_studio_DisplayData(tolua_S);
lua_register_cocos2dx_studio_ArmatureDisplayData(tolua_S);
lua_register_cocos2dx_studio_MovementData(tolua_S);

View File

@ -298,6 +298,11 @@ int register_all_cocos2dx_studio(lua_State* tolua_S);

2
plugin

@ -1 +1 @@
Subproject commit 51ceded726cc034cdc939e379e1b24249e0ebad4
Subproject commit 4a8c94a85a08cddbea5e1bc499c50cce7518fb15

View File

@ -444,6 +444,17 @@
"cocos/editor-support/cocosbuilder/proj.wp8/libCocosBuilder.vcxproj.user",
"cocos/editor-support/cocosbuilder/proj.wp8/pch.cpp",
"cocos/editor-support/cocosbuilder/proj.wp8/pch.h",
"cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp",
"cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h",
"cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp",
"cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h",
"cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp",
"cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h",
"cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp",
"cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.h",
"cocos/editor-support/cocostudio/ActionTimeline/CCTimeLine.cpp",
"cocos/editor-support/cocostudio/ActionTimeline/CCTimeLine.h",
"cocos/editor-support/cocostudio/ActionTimeline/CCTimelineMacro.h",
"cocos/editor-support/cocostudio/Android.mk",
"cocos/editor-support/cocostudio/CCActionFrame.cpp",
"cocos/editor-support/cocostudio/CCActionFrame.h",
@ -3516,6 +3527,7 @@
"cocos/scripting/lua-bindings/auto/api/ActionManager.lua",
"cocos/scripting/lua-bindings/auto/api/ActionManagerEx.lua",
"cocos/scripting/lua-bindings/auto/api/ActionObject.lua",
"cocos/scripting/lua-bindings/auto/api/ActionTimelineData.lua",
"cocos/scripting/lua-bindings/auto/api/ActionTween.lua",
"cocos/scripting/lua-bindings/auto/api/Animate.lua",
"cocos/scripting/lua-bindings/auto/api/Animation.lua",

View File

@ -122,7 +122,6 @@
"exclude": [
"proj.android/bin",
"proj.android/assets",
"proj.android/libs",
"proj.ios_mac/HelloLua.xcodeproj/project.xcworkspace",
"proj.ios_mac/HelloLua.xcodeproj/xcuserdata",
"proj.win32/Debug.win32",

View File

@ -73,7 +73,3 @@ else()
endif()
target_link_libraries(${APP_NAME} audio cocos2d)
# MinGW builds need to link libws2_32 and libglew32 manually
if (MINGW)
target_link_libraries(${APP_NAME} glew32 ws2_32)
endif()

View File

@ -54,6 +54,7 @@ Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \
Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \
Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp \
Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp \
Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp \
Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp \
Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp \
Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp \

View File

@ -65,6 +65,7 @@ set(SAMPLE_SRC
Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp
Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp
Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp
Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp
Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp
Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp
Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp
@ -202,10 +203,6 @@ target_link_libraries(${APP_NAME}
cocos2d
box2d
)
# MinGW builds need to link libws2_32 manually
if (MINGW)
target_link_libraries(${APP_NAME} ws2_32)
endif()
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}")

View File

@ -0,0 +1,325 @@
#include "ActionTimelineTestScene.h"
#include "../../testResource.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCCustomCommand.h"
using namespace cocos2d;
using namespace cocostudio;
Layer *NextAnimationTest();
Layer *BackAnimationTest();
Layer *RestartAnimationTest();
static int s_nActionIdx = -1;
Layer *CreateAnimationLayer(int index)
{
Layer *pLayer = nullptr;
switch(index)
{
case TEST_ANIMATIONELEMENT:
pLayer = new TestActionTimeline();
break;
case TEST_CHANGE_PLAY_SECTION:
pLayer = new TestChangePlaySection();
break;
case TEST_TIMELINE_FRAME_EVENT:
pLayer = new TestTimelineFrameEvent();
break;
case TEST_TIMELINE_PERFORMACE:
pLayer = new TestTimelinePerformance();
break;
default:
break;
}
return pLayer;
}
Layer *NextAnimationTest()
{
++s_nActionIdx;
s_nActionIdx = s_nActionIdx % TEST_ANIMATION_LAYER_COUNT;
Layer *pLayer = CreateAnimationLayer(s_nActionIdx);
pLayer->autorelease();
return pLayer;
}
Layer *BackAnimationTest()
{
--s_nActionIdx;
if( s_nActionIdx < 0 )
s_nActionIdx += TEST_ANIMATION_LAYER_COUNT;
Layer *pLayer = CreateAnimationLayer(s_nActionIdx);
pLayer->autorelease();
return pLayer;
}
Layer *RestartAnimationTest()
{
Layer *pLayer = CreateAnimationLayer(s_nActionIdx);
pLayer->autorelease();
return pLayer;
}
ActionTimelineTestScene::ActionTimelineTestScene(bool bPortrait)
{
TestScene::init();
Sprite *bg = Sprite::create("armature/bg.jpg");
bg->setPosition(VisibleRect::center());
float scaleX = VisibleRect::getVisibleRect().size.width / bg->getContentSize().width;
float scaleY = VisibleRect::getVisibleRect().size.height / bg->getContentSize().height;
bg->setScaleX(scaleX);
bg->setScaleY(scaleY);
addChild(bg);
}
void ActionTimelineTestScene::runThisTest()
{
s_nActionIdx = -1;
addChild(NextAnimationTest());
Director::getInstance()->replaceScene(this);
}
void ActionTimelineTestScene::MainMenuCallback(Ref *pSender)
{
//TestScene::MainMenuCallback(pSender);
removeAllChildren();
}
void ActionTimelineTestLayer::onEnter()
{
Layer::onEnter();
// add title and subtitle
std::string str = title();
const char *pTitle = str.c_str();
LabelTTF *label = LabelTTF::create(pTitle, "Arial", 18);
label->setColor(Color3B(0, 0, 0));
addChild(label, 1, 10000);
label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 30) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
LabelTTF *l = LabelTTF::create(strSubtitle.c_str(), "Arial", 18);
l->setColor(Color3B(0, 0, 0));
addChild(l, 1, 10001);
l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
// add menu
backItem = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(ActionTimelineTestLayer::backCallback, this) );
restartItem = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(ActionTimelineTestLayer::restartCallback, this) );
nextItem = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(ActionTimelineTestLayer::nextCallback, this) );
Menu *menu = Menu::create(backItem, restartItem, nextItem, nullptr);
menu->setPosition(Point::ZERO);
backItem->setPosition(Point(VisibleRect::center().x - restartItem->getContentSize().width * 2, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
restartItem->setPosition(Point(VisibleRect::center().x, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
nextItem->setPosition(Point(VisibleRect::center().x + restartItem->getContentSize().width * 2, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
addChild(menu, 100);
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
}
void ActionTimelineTestLayer::onExit()
{
removeAllChildren();
backItem = restartItem = nextItem = nullptr;
ActionTimelineCache::getInstance()->purge();
NodeReader::getInstance()->purge();
Layer::onExit();
}
std::string ActionTimelineTestLayer::title() const
{
return "Armature Test Bed";
}
std::string ActionTimelineTestLayer::subtitle() const
{
return "";
}
void ActionTimelineTestLayer::restartCallback(Ref *pSender)
{
Scene *s = new ActionTimelineTestScene();
s->addChild( RestartAnimationTest() );
Director::getInstance()->replaceScene(s);
s->release();
}
void ActionTimelineTestLayer::nextCallback(Ref *pSender)
{
Scene *s = new ActionTimelineTestScene();
s->addChild( NextAnimationTest() );
Director::getInstance()->replaceScene(s);
s->release();
}
void ActionTimelineTestLayer::backCallback(Ref *pSender)
{
Scene *s = new ActionTimelineTestScene();
s->addChild( BackAnimationTest() );
Director::getInstance()->replaceScene(s);
s->release();
}
// TestActionTimeline
void TestActionTimeline::onEnter()
{
ActionTimelineTestLayer::onEnter();
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("armature/Cowboy0.plist", "armature/Cowboy0.png");
Node* node = NodeReader::getInstance()->createNode("ActionTimeline/boy_1.ExportJson");
ActionTimeline* action = ActionTimelineCache::getInstance()->createAction("ActionTimeline/boy_1.ExportJson");
node->runAction(action);
action->gotoFrameAndPlay(0, 60, true);
node->setScale(0.2f);
node->setPosition(150,100);
addChild(node);
}
std::string TestActionTimeline::title() const
{
return "Test ActionTimeline";
}
// TestActionTimeline
void TestChangePlaySection::onEnter()
{
ActionTimelineTestLayer::onEnter();
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("armature/Cowboy0.plist", "armature/Cowboy0.png");
Node* node = NodeReader::getInstance()->createNode("ActionTimeline/boy_1.ExportJson");
action = ActionTimelineCache::getInstance()->createAction("ActionTimeline/boy_1.ExportJson");
node->runAction(action);
action->gotoFrameAndPlay(70, action->getDuration(), true);
node->setScale(0.2f);
node->setPosition(150,100);
// add touch event listener
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesEnded = CC_CALLBACK_2(TestChangePlaySection::onTouchesEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
addChild(node);
}
std::string TestChangePlaySection::title() const
{
return "Test Change Play Section";
}
void TestChangePlaySection::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)
{
if(action->getStartFrame() == 0)
action->gotoFrameAndPlay(70, action->getDuration(), true);
else
action->gotoFrameAndPlay(0, 60, true);
}
// TestFrameEvent
void TestTimelineFrameEvent::onEnter()
{
ActionTimelineTestLayer::onEnter();
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("armature/Cowboy0.plist", "armature/Cowboy0.png");
Node* node = NodeReader::getInstance()->createNode("ActionTimeline/boy_1.ExportJson");
ActionTimeline* action = ActionTimelineCache::getInstance()->createAction("ActionTimeline/boy_1.ExportJson");
node->runAction(action);
action->gotoFrameAndPlay(0, 60, true);
node->setScale(0.2f);
node->setPosition(150,100);
addChild(node);
action->setFrameEventCallFunc(CC_CALLBACK_1(TestTimelineFrameEvent::onFrameEvent, this));
}
std::string TestTimelineFrameEvent::title() const
{
return "Test Frame Event";
}
void TestTimelineFrameEvent::onFrameEvent(Frame* frame)
{
EventFrame* evnt = dynamic_cast<EventFrame*>(frame);
if(!evnt)
return;
std::string str = evnt->getEvent();
if (str == "changeColor")
{
evnt->getNode()->setColor(Color3B(0,0,0));
}
else if(str == "endChangeColor")
{
evnt->getNode()->setColor(Color3B(255,255,255));
}
}
// TestTimelinePerformance
void TestTimelinePerformance::onEnter()
{
ActionTimelineTestLayer::onEnter();
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("armature/Cowboy0.plist", "armature/Cowboy0.png");
for (int i = 0; i< 100; i++)
{
Node* node = NodeReader::getInstance()->createNode("ActionTimeline/boy_1.ExportJson");
ActionTimeline* action = ActionTimelineCache::getInstance()->createAction("ActionTimeline/boy_1.ExportJson");
node->runAction(action);
action->gotoFrameAndPlay(70, action->getDuration(), true);
node->setScale(0.1f);
node->setPosition(i*2,100);
addChild(node);
}
}
std::string TestTimelinePerformance::title() const
{
return "Test ActionTimeline performance";
}

View File

@ -0,0 +1,88 @@
#ifndef __ANIMATION_TEST_SCENE_H__
#define __ANIMATION_TEST_SCENE_H__
#include "cocos2d.h"
#include "../../VisibleRect.h"
#include "../../testBasic.h"
#include "cocostudio/CocoStudio.h"
using namespace cocostudio::timeline;
class ActionTimelineTestScene : public TestScene
{
public:
ActionTimelineTestScene(bool bPortrait = false);
virtual void runThisTest();
// The CallBack for back to the main menu scene
virtual void MainMenuCallback(Ref* pSender);
};
enum {
TEST_ANIMATIONELEMENT = 0,
TEST_CHANGE_PLAY_SECTION,
TEST_TIMELINE_FRAME_EVENT,
TEST_TIMELINE_PERFORMACE,
TEST_ANIMATION_LAYER_COUNT
};
class ActionTimelineTestLayer : public Layer
{
public:
virtual std::string title() const;
virtual std::string subtitle() const;
virtual void restartCallback(Ref* pSender);
virtual void nextCallback(Ref* pSender);
virtual void backCallback(Ref* pSender);
// overrides
virtual void onEnter() override;
virtual void onExit() override;
protected:
MenuItemImage *restartItem;
MenuItemImage *nextItem;
MenuItemImage *backItem;
};
class TestActionTimeline : public ActionTimelineTestLayer
{
public:
virtual void onEnter();
virtual std::string title() const override;
};
class TestChangePlaySection : public ActionTimelineTestLayer
{
public:
virtual void onEnter();
virtual std::string title() const override;
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
protected:
ActionTimeline* action;
};
class TestTimelineFrameEvent : public ActionTimelineTestLayer
{
public:
virtual void onEnter();
virtual std::string title() const override;
void onFrameEvent(Frame* frame);
};
class TestTimelinePerformance : public ActionTimelineTestLayer
{
public:
virtual void onEnter();
virtual std::string title() const override;
};
#endif // __ANIMATION_SCENE_H__

View File

@ -411,10 +411,10 @@ void TestPerformance::addArmature(int number)
Armature *armature = nullptr;
armature = new Armature();
armature->init("Knight_f/Knight");
armature->init("Cowboy");
armature->getAnimation()->playWithIndex(0);
armature->setPosition(50 + armatureCount * 2, 150);
armature->setScale(0.6f);
armature->setScale(0.1f);
addArmatureToParent(armature);
armature->release();
}

View File

@ -9,6 +9,7 @@
#include "TableViewTest/TableViewTestScene.h"
#include "CocoStudioArmatureTest/ArmatureScene.h"
#include "CocoStudioActionTimelineTest/ActionTimelineTestScene.h"
#include "CocoStudioComponentsTest/ComponentsTestScene.h"
#include "CocoStudioSceneTest/SceneEditorTest.h"
@ -78,6 +79,11 @@ static struct {
scene->release();
}
},
{ "CocoStudioActionTimelineTest", [](Ref *sender) { ActionTimelineTestScene *scene = new ActionTimelineTestScene();
scene->runThisTest();
scene->release();
}
},
{ "CocoStudioComponentsTest", [](Ref *sender) { runComponentsTestLayerTest(); }
},
{ "CocoStudioSceneTest", [](Ref *sender) { SceneEditorTestScene *scene = new SceneEditorTestScene();

View File

@ -78,7 +78,9 @@ static std::function<Layer*()> createFunctions[] =
CL(LabelFontNameTest),
CL(LabelAlignmentTest),
CL(LabelIssue4428Test),
CL(LabelIssue4999Test)
CL(LabelIssue4999Test),
CL(LabelLineHeightTest),
CL(LabelAdditionalKerningTest)
};
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
@ -1773,3 +1775,91 @@ std::string LabelIssue4999Test::subtitle() const
{
return "Reorder issue #4999.The label should be display cleanly.";
}
LabelLineHeightTest::LabelLineHeightTest()
{
auto size = Director::getInstance()->getWinSize();
auto bg = LayerColor::create(Color4B(200,191,231,255));
this->addChild(bg);
TTFConfig ttfConfig("fonts/arial.ttf", 25, GlyphCollection::DYNAMIC,nullptr,false);
label = Label::createWithTTF(ttfConfig,"Test\nLine\nHeight");
label->setPosition( Vec2(size.width/2, size.height*0.5f) );
label->setTextColor( Color4B::RED );
addChild(label);
auto slider = ui::Slider::create();
slider->setTouchEnabled(true);
slider->loadBarTexture("cocosui/sliderTrack.png");
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getSize().height * 2.0f));
slider->setPercent(label->getLineHeight());
slider->addEventListener(CC_CALLBACK_2(LabelLineHeightTest::sliderEvent, this));
addChild(slider);
}
void LabelLineHeightTest::sliderEvent(Ref *sender, ui::Slider::EventType type)
{
if (type == Slider::EventType::ON_PERCENTAGE_CHANGED)
{
Slider* slider = (Slider*)sender;
label->setLineHeight(slider->getPercent());
}
}
std::string LabelLineHeightTest::title() const
{
return "New Label";
}
std::string LabelLineHeightTest::subtitle() const
{
return "Testing line height of label";
}
LabelAdditionalKerningTest::LabelAdditionalKerningTest()
{
auto size = Director::getInstance()->getWinSize();
auto bg = LayerColor::create(Color4B(200,191,231,255));
this->addChild(bg);
TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC,nullptr,false);
label = Label::createWithTTF(ttfConfig,"Test additional kerning");
label->setPosition( Vec2(size.width/2, size.height*0.65f) );
label->setTextColor( Color4B::RED );
addChild(label);
auto slider = ui::Slider::create();
slider->setTouchEnabled(true);
slider->loadBarTexture("cocosui/sliderTrack.png");
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getSize().height * 2.0f));
slider->setPercent(0);
slider->addEventListener(CC_CALLBACK_2(LabelAdditionalKerningTest::sliderEvent, this));
addChild(slider);
}
void LabelAdditionalKerningTest::sliderEvent(Ref *sender, ui::Slider::EventType type)
{
if (type == Slider::EventType::ON_PERCENTAGE_CHANGED)
{
Slider* slider = (Slider*)sender;
label->setAdditionalKerning(slider->getPercent());
}
}
std::string LabelAdditionalKerningTest::title() const
{
return "New Label";
}
std::string LabelAdditionalKerningTest::subtitle() const
{
return "Testing additional kerning of label";
}

View File

@ -496,6 +496,36 @@ public:
virtual std::string subtitle() const override;
};
class LabelLineHeightTest : public AtlasDemoNew
{
public:
CREATE_FUNC(LabelLineHeightTest);
LabelLineHeightTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
void sliderEvent(Ref *sender, ui::Slider::EventType type);
private:
Label* label;
};
class LabelAdditionalKerningTest : public AtlasDemoNew
{
public:
CREATE_FUNC(LabelAdditionalKerningTest);
LabelAdditionalKerningTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
void sliderEvent(Ref *sender, ui::Slider::EventType type);
private:
Label* label;
};
// we don't support linebreak mode
#endif

View File

@ -541,12 +541,13 @@ std::string Sprite3DWithSkinTest::subtitle() const
void Sprite3DWithSkinTest::addNewSpriteWithCoords(Vec2 p)
{
auto sprite = Sprite3D::create("Sprite3DTest/girl.c3t");
std::string fileName = "Sprite3DTest/scene.c3b";
auto sprite = Sprite3D::create(fileName);
addChild(sprite);
sprite->setRotation3D(Vec3(-90.f, 0.f, 0.f));
sprite->setPosition( Vec2( p.x, p.y) );
auto animation = Animation3D::getOrCreate("Sprite3DTest/girl.c3t");
auto animation = Animation3D::getOrCreate(fileName);
if (animation)
{
auto animate = Animate3D::create(animation);

File diff suppressed because it is too large Load Diff

View File

@ -149,6 +149,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(Ou
<ClCompile Include="..\Classes\DataVisitorTest\DataVisitorTest.cpp" />
<ClCompile Include="..\Classes\ExtensionsTest\CocosBuilderTest\AnimationsTest\AnimationsTestLayer.cpp" />
<ClCompile Include="..\Classes\ExtensionsTest\CocosBuilderTest\TimelineCallbackTest\TimelineCallbackTestLayer.cpp" />
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioActionTimelineTest\ActionTimelineTestScene.cpp" />
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioArmatureTest\ArmatureScene.cpp" />
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\ComponentsTestScene.cpp" />
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\EnemyController.cpp" />
@ -329,6 +330,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(Ou
<ClInclude Include="..\Classes\ExtensionsTest\CocosBuilderTest\AnimationsTest\AnimationsTestLayer.h" />
<ClInclude Include="..\Classes\ExtensionsTest\CocosBuilderTest\TimelineCallbackTest\TimelineCallbackLayerLoader.h" />
<ClInclude Include="..\Classes\ExtensionsTest\CocosBuilderTest\TimelineCallbackTest\TimelineCallbackTestLayer.h" />
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioActionTimelineTest\ActionTimelineTestScene.h" />
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioArmatureTest\ArmatureScene.h" />
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\ComponentsTestScene.h" />
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\EnemyController.h" />

View File

@ -325,6 +325,9 @@
<Filter Include="Classes\Sprite3DTest">
<UniqueIdentifier>{45e9becf-58e5-424e-903d-9bc7f9999d5b}</UniqueIdentifier>
</Filter>
<Filter Include="Classes\ExtensionsTest\CocoStudioActionTimelineTest">
<UniqueIdentifier>{fa88df83-76d7-4f41-ad48-801dafd44889}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
@ -840,6 +843,9 @@
<ClCompile Include="..\Classes\Sprite3DTest\Sprite3DTest.cpp">
<Filter>Classes\Sprite3DTest</Filter>
</ClCompile>
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioActionTimelineTest\ActionTimelineTestScene.cpp">
<Filter>Classes\ExtensionsTest\CocoStudioActionTimelineTest</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h">
@ -1553,5 +1559,8 @@
<ClInclude Include="..\Classes\Sprite3DTest\Sprite3DTest.h">
<Filter>Classes\Sprite3DTest</Filter>
</ClInclude>
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioActionTimelineTest\ActionTimelineTestScene.h">
<Filter>Classes\ExtensionsTest\CocoStudioActionTimelineTest</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -48,8 +48,10 @@ bool AppDelegate::applicationDidFinishLaunching()
LuaEngine* pEngine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(pEngine);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID ||CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
LuaStack* stack = pEngine->getLuaStack();
stack->setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA"));
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID ||CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
register_assetsmanager_test_sample(stack->getLuaState());
#endif

View File

@ -0,0 +1,104 @@
require("src/ByteCodeEncryptTest/ByteCodeTest")
require("src/ByteCodeEncryptTest/ByteCodeAndEncryptTest")
local LINE_SPACE = 40
local ItemTagBasic = 1000
local ByteCodeEncryptEnum =
{
TEST_BYTECODE = 0,
TEST_BYTECODE_ENCRYPT = 1,
TEST_MAX_COUNT = 2,
}
local TestsName =
{
"ByteCodeFileTest",
"ByteCodeAndEncryptFileTest",
}
local CreateByteCodeEncryptTestTable =
{
runByteCodeFileTest,
runByteCodeAndEncryptFileTest,
}
local function byteCodeEncryptMainLayer()
local size = cc.Director:getInstance():getWinSize()
local function createByteCodeEncryptTestScene(index)
local newScene = CreateByteCodeEncryptTestTable[index]()
return newScene
end
local function menuCallback(tag, sender)
local scene = nil
local index = sender:getLocalZOrder() - ItemTagBasic
local byteCodeEncryptScene = createByteCodeEncryptTestScene(index)
if nil ~= byteCodeEncryptScene then
cc.Director:getInstance():replaceScene(byteCodeEncryptScene)
end
end
local layer = cc.Layer:create()
local menu = cc.Menu:create()
menu:setPosition(cc.p(0, 0))
cc.MenuItemFont:setFontName("Arial")
cc.MenuItemFont:setFontSize(24)
for i = 1, ByteCodeEncryptEnum.TEST_MAX_COUNT do
local item = cc.MenuItemFont:create(TestsName[i])
item:registerScriptTapHandler(menuCallback)
item:setPosition(size.width / 2, size.height - i * LINE_SPACE)
menu:addChild(item, ItemTagBasic + i)
end
layer:addChild(menu)
-- handling touch events
local beginPos = {x = 0, y = 0}
local function onTouchesBegan(touches, event)
beginPos = touches[1]:getLocation()
end
local function onTouchesMoved(touches, event)
local location = touches[1]:getLocation()
local nMoveY = location.y - beginPos.y
local curPosx, curPosy = menu:getPosition()
local nextPosy = curPosy + nMoveY
local winSize = cc.Director:getInstance():getWinSize()
if nextPosy < 0 then
menu:setPosition(0, 0)
return
end
if nextPosy > ((ByteCodeEncryptEnum.TEST_MAX_COUNT + 1) * LINE_SPACE - winSize.height) then
menu:setPosition(0, ((ByteCodeEncryptEnum.TEST_MAX_COUNT + 1) * LINE_SPACE - winSize.height))
return
end
menu:setPosition(curPosx, nextPosy)
beginPos = {x = location.x, y = location.y}
end
local listener = cc.EventListenerTouchAllAtOnce:create()
listener:registerScriptHandler(onTouchesBegan,cc.Handler.EVENT_TOUCHES_BEGAN )
listener:registerScriptHandler(onTouchesMoved,cc.Handler.EVENT_TOUCH_MOVED )
local eventDispatcher = layer:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer)
return layer
end
-------------------------------------
-- ByteCodeEncrypt Test
-------------------------------------
function ByteCodeEncryptTestMain()
local scene = cc.Scene:create()
scene:addChild(byteCodeEncryptMainLayer())
scene:addChild(CreateBackMenuItem())
return scene
end

View File

@ -15,6 +15,7 @@ require "src/ActionsProgressTest/ActionsProgressTest"
require "src/ActionsTest/ActionsTest"
require "src/AssetsManagerTest/AssetsManagerTest"
require "src/BugsTest/BugsTest"
require "src/ByteCodeEncryptTest/ByteCodeEncryptTest"
require "src/ClickAndMoveTest/ClickAndMoveTest"
require "src/CocosDenshionTest/CocosDenshionTest"
require "src/CocoStudioTest/CocoStudioTest"
@ -70,6 +71,7 @@ local _allTests = {
{ isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain },
{ isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain },
{ isSupported = true, name = "BugsTest" , create_func= BugsTestMain },
{ isSupported = true, name = "ByteCodeEncryptTest" , create_func= ByteCodeEncryptTestMain },
{ isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain },
{ isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest },
{ isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain },

@ -1 +1 @@
Subproject commit 79153cce443f3efbfd79c08835c63ec58a6c1462
Subproject commit 5f3bf19c5d59903662571c722fe4b34cae7e9404

@ -1 +1 @@
Subproject commit f5037bab73a8fb109e8e34656220bed1a1743087
Subproject commit 3164639ee44570d7cd3efb3c511e52077560e6fb

View File

@ -37,7 +37,7 @@ classes = Skeleton SkeletonAnimation
# functions from all classes.
skip = Skeleton::[findBone findSlot getAttachment setAttachment update draw createWith.*],
SkeletonAnimation::[addAnimationState setAnimationStateData update createWith.* (s|g)etBlendFunc addAnimation getCurrent setAnimation onAnimationStateEvent]
SkeletonAnimation::[addAnimationState setAnimationStateData update createWith.* (s|g)etBlendFunc addAnimation getCurrent setAnimation]
rename_functions =