mirror of https://github.com/axmolengine/axmol.git
commit
0d07e19cd1
|
@ -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 */,
|
||||
|
|
|
@ -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 */,
|
||||
|
|
|
@ -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
|
|
@ -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__*/
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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__*/
|
|
@ -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
|
|
@ -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__*/
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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__*/
|
|
@ -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
|
|
@ -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__*/
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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>
|
||||
</Project>
|
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
@ -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__
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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" />
|
||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue