diff --git a/spine-cocos2dx/example/Classes/ExampleLayer.cpp b/spine-cocos2dx/example/Classes/ExampleLayer.cpp index eef36b07b..ddbfc3a53 100644 --- a/spine-cocos2dx/example/Classes/ExampleLayer.cpp +++ b/spine-cocos2dx/example/Classes/ExampleLayer.cpp @@ -15,21 +15,22 @@ CCScene* ExampleLayer::scene () { bool ExampleLayer::init () { if (!CCLayer::init()) return false; - atlas = new Atlas("spineboy.txt"); - SkeletonJson json(atlas); - json.scale = 0.5; - skeletonData = json.readSkeletonData("spineboy-skeleton.json"); - animation = json.readAnimation("spineboy-walk.json", skeletonData); + atlas = Atlas_readAtlasFile("spineboy.atlas"); + SkeletonJson* json = SkeletonJson_create(atlas); + json->scale = 0.75; + skeletonData = SkeletonJson_readSkeletonDataFile(json, "spineboy-skeleton.json"); + animation = SkeletonJson_readAnimationFile(json, "spineboy-walk.json", skeletonData); + SkeletonJson_dispose(json); CCSkeleton* skeletonNode = CCSkeleton::create(skeletonData); - skeletonNode->state->setAnimation(animation, true); - skeletonNode->debug = true; - - CCAction* fade = CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1), - CCFadeIn::create(1), - CCDelayTime::create(5), - NULL)); - skeletonNode->runAction(fade); + Skeleton_setToBindPose(skeletonNode->skeleton); + AnimationState_setAnimation(skeletonNode->state, animation, true); + skeletonNode->debugBones = true; + + /*skeletonNode->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1), + CCFadeIn::create(1), + CCDelayTime::create(5), + NULL)));*/ CCSize windowSize = CCDirector::sharedDirector()->getWinSize(); skeletonNode->setPosition(ccp(windowSize.width / 2, 20)); @@ -39,7 +40,7 @@ bool ExampleLayer::init () { } ExampleLayer::~ExampleLayer () { - delete atlas; - delete skeletonData; - delete animation; + SkeletonData_dispose(skeletonData); + Animation_dispose(animation); + Atlas_dispose(atlas); } diff --git a/spine-cocos2dx/example/Classes/ExampleLayer.h b/spine-cocos2dx/example/Classes/ExampleLayer.h index 9935f6aaf..64c7a085a 100644 --- a/spine-cocos2dx/example/Classes/ExampleLayer.h +++ b/spine-cocos2dx/example/Classes/ExampleLayer.h @@ -2,7 +2,7 @@ #define _EXAMPLELAYER_H_ #include "cocos2d.h" -#include +#include class ExampleLayer: public cocos2d::CCLayer { private: diff --git a/spine-cocos2dx/example/Resources/common/spineboy-bow.json b/spine-cocos2dx/example/Resources/common/spineboy-bow.json deleted file mode 100644 index 7807e29a1..000000000 --- a/spine-cocos2dx/example/Resources/common/spineboy-bow.json +++ /dev/null @@ -1,204 +0,0 @@ -{ -"bones": { - "torso": { - "rotate": [ - { - "time": 0, - "angle": -16.96, - "curve": [ 0.356, 0.01, 0.827, 0.82 ] - }, - { - "time": 0.7333, - "angle": -33.3, - "curve": [ 0.137, 0.2, 0.652, 0.86 ] - }, - { "time": 1.6, "angle": -8.18 }, - { "time": 2.3333, "angle": 1.82 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - }, - "neck": { - "rotate": [ - { "time": 0, "angle": 10.71 }, - { - "time": 0.7333, - "angle": -12.37, - "curve": [ 0.137, 0.2, 0.652, 0.86 ] - }, - { "time": 2.3333, "angle": 12.74 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0 }, - { - "time": 0.7333, - "x": -1.67, - "y": -3.3, - "curve": [ 0.137, 0.2, 0.652, 0.86 ] - }, - { "time": 2.3333, "x": -1.04, "y": -0.38 } - ] - }, - "head": { - "rotate": [ - { "time": 0, "angle": 12.63 }, - { - "time": 0.7333, - "angle": 10.39, - "curve": [ 0.137, 0.2, 0.652, 0.86 ] - }, - { "time": 2.3333, "angle": -11.41 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0 }, - { "time": 0.7333, "x": -0.85, "y": -5.38 }, - { "time": 2.3333, "x": 1.02, "y": 4.99 } - ] - }, - "right shoulder": { - "rotate": [ - { "time": 0, "angle": -7.36 }, - { "time": 0.7333, "angle": -229.15 }, - { "time": 1.9666, "angle": -12.04 }, - { "time": 2.5666, "angle": -39.4 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0 }, - { "time": 0.7333, "x": -3.78, "y": -8.32 }, - { - "time": 1.2666, - "x": -2.26, - "y": 1.26, - "curve": [ 0.08, 0.08, 0.75, 1 ] - }, - { "time": 1.9666, "x": -5.25, "y": 7.6 }, - { "time": 2.5666, "x": -5.58, "y": 13.32 } - ] - }, - "right arm": { - "rotate": [ - { "time": 0, "angle": 6.19 }, - { "time": 0.7333, "angle": 19.54 }, - { - "time": 1.2666, - "angle": 90.5, - "curve": [ 0.08, 0.08, 0.75, 1 ] - }, - { "time": 1.9666, "angle": 124.15 }, - { "time": 2.5666, "angle": 133.59 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - }, - "left shoulder": { - "rotate": [ - { "time": 0, "angle": -21.47 }, - { "time": 0.7333, "angle": 94.34 }, - { - "time": 1.4333, - "angle": 60.17, - "curve": [ 0.08, 0.08, 0.75, 1 ] - }, - { "time": 1.8666, "angle": 78.57 }, - { "time": 2.3333, "angle": 68.5 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0 }, - { "time": 0.7333, "x": -8.29, "y": 5.93 }, - { "time": 1.8666, "x": -4.3, "y": -5.12 } - ] - }, - "left arm": { - "rotate": [ - { "time": 0, "angle": 56.2 }, - { "time": 0.7333, "angle": -28.44 }, - { - "time": 1.2666, - "angle": -10.8, - "curve": [ 0.08, 0.08, 0.75, 1 ] - }, - { "time": 1.8666, "angle": -43.07 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0 }, - { "time": 1.8666, "x": 2.71, "y": 0.13 } - ] - }, - "right hand": { - "rotate": [ - { "time": 0, "angle": 0 }, - { "time": 0.7333, "angle": -18.22 }, - { - "time": 1.2666, - "angle": -33.49, - "curve": [ 0.08, 0.08, 0.75, 1 ] - }, - { "time": 1.9666, "angle": -3.98 }, - { "time": 2.5666, "angle": 1.45 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - }, - "left hand": { - "rotate": [ - { "time": 0, "angle": 0 }, - { "time": 0.7333, "angle": -30.39 }, - { "time": 1.9666, "angle": -11.61 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0 }, - { "time": 1.8666, "x": 2.71, "y": -0.04 } - ] - }, - "hip": { - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - }, - "left upper leg": { - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - }, - "left lower leg": { - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - }, - "left foot": { - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - }, - "right upper leg": { - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - }, - "right lower leg": { - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - }, - "right foot": { - "translate": [ - { "time": 0, "x": 0, "y": 0 } - ] - } -}, -"slots": { - "left hand item": { - "attachment": [ - { "time": 0, "name": "bow" } - ] - }, - "left hand": { - "attachment": [ - { "time": 0, "name": null } - ] - } -} -} \ No newline at end of file diff --git a/spine-cocos2dx/example/Resources/common/spineboy-jump.json b/spine-cocos2dx/example/Resources/common/spineboy-jump.json deleted file mode 100644 index 82a6f47be..000000000 --- a/spine-cocos2dx/example/Resources/common/spineboy-jump.json +++ /dev/null @@ -1,372 +0,0 @@ -{ -"bones": { - "hip": { - "rotate": [ - { "time": 0, "angle": 0, "curve": "stepped" }, - { "time": 0.9333, "angle": 0, "curve": "stepped" }, - { "time": 1.3666, "angle": 0 } - ], - "translate": [ - { "time": 0, "x": -11.57, "y": -3 }, - { "time": 0.2333, "x": -16.2, "y": -19.43 }, - { "time": 0.3333, "x": 7.66, "y": -8.47 }, - { "time": 0.3666, "x": 15.38, "y": 5.01 }, - { "time": 0.4666, "x": -7.84, "y": 57.22 }, - { "time": 0.6, "x": -10.81, "y": 96.34 }, - { "time": 0.7332, "x": -7.01, "y": 54.7 }, - { "time": 0.8, "x": -10.58, "y": 32.2 }, - { "time": 0.9333, "x": -31.99, "y": 0.45 }, - { "time": 1.0666, "x": -12.48, "y": -29.47 }, - { "time": 1.3666, "x": -11.57, "y": -3 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "left upper leg": { - "rotate": [ - { "time": 0, "angle": 17.12 }, - { "time": 0.2333, "angle": 44.35 }, - { "time": 0.3333, "angle": 16.45 }, - { "time": 0.4, "angle": -9.88 }, - { "time": 0.4666, "angle": -11.42 }, - { "time": 0.5666, "angle": 23.46 }, - { "time": 0.7666, "angle": 71.82 }, - { "time": 0.9333, "angle": 65.53 }, - { "time": 1.0666, "angle": 51.01 }, - { "time": 1.3666, "angle": 17.12 } - ], - "translate": [ - { "time": 0, "x": -3, "y": -2.25, "curve": "stepped" }, - { "time": 0.9333, "x": -3, "y": -2.25, "curve": "stepped" }, - { "time": 1.3666, "x": -3, "y": -2.25 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "left lower leg": { - "rotate": [ - { "time": 0, "angle": -16.25 }, - { "time": 0.2333, "angle": -52.21 }, - { "time": 0.4, "angle": 15.04 }, - { "time": 0.4666, "angle": -8.95 }, - { "time": 0.5666, "angle": -39.53 }, - { "time": 0.7666, "angle": -27.27 }, - { "time": 0.9333, "angle": -3.52 }, - { "time": 1.0666, "angle": -61.92 }, - { "time": 1.3666, "angle": -16.25 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "left foot": { - "rotate": [ - { "time": 0, "angle": 0.33 }, - { "time": 0.2333, "angle": 6.2 }, - { "time": 0.3333, "angle": 14.73 }, - { "time": 0.4, "angle": -15.54 }, - { "time": 0.4333, "angle": -21.2 }, - { "time": 0.5666, "angle": -7.55 }, - { "time": 0.7666, "angle": -0.67 }, - { "time": 0.9333, "angle": -0.58 }, - { "time": 1.0666, "angle": 14.64 }, - { "time": 1.3666, "angle": 0.33 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "right upper leg": { - "rotate": [ - { "time": 0, "angle": 25.97 }, - { "time": 0.2333, "angle": 46.43 }, - { "time": 0.3333, "angle": 22.61 }, - { "time": 0.4, "angle": 2.13 }, - { "time": 0.4666, "angle": 0.04 }, - { "time": 0.6, "angle": 65.55 }, - { "time": 0.7666, "angle": 64.93 }, - { "time": 0.9333, "angle": 41.08 }, - { "time": 1.0666, "angle": 66.25 }, - { "time": 1.3666, "angle": 25.97 } - ], - "translate": [ - { "time": 0, "x": 5.74, "y": 0.61 }, - { "time": 0.2333, "x": 4.79, "y": 1.79 }, - { "time": 0.3333, "x": 6.05, "y": -4.55 }, - { "time": 0.9333, "x": 4.79, "y": 1.79, "curve": "stepped" }, - { "time": 1.0666, "x": 4.79, "y": 1.79 }, - { "time": 1.3666, "x": 5.74, "y": 0.61 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "right lower leg": { - "rotate": [ - { "time": 0, "angle": -27.46 }, - { "time": 0.2333, "angle": -64.03 }, - { "time": 0.4, "angle": -48.36 }, - { "time": 0.5666, "angle": -76.86 }, - { "time": 0.7666, "angle": -26.89 }, - { "time": 0.9, "angle": -18.96 }, - { "time": 0.9333, "angle": -14.18 }, - { "time": 1.0666, "angle": -80.44 }, - { "time": 1.3666, "angle": -27.46 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "right foot": { - "rotate": [ - { "time": 0, "angle": 1.08 }, - { "time": 0.2333, "angle": 16.02 }, - { "time": 0.3, "angle": 12.94 }, - { "time": 0.3333, "angle": 15.16 }, - { "time": 0.4, "angle": -14.7 }, - { "time": 0.4333, "angle": -12.85 }, - { "time": 0.4666, "angle": -19.18 }, - { "time": 0.5666, "angle": -15.82 }, - { "time": 0.6, "angle": -3.59 }, - { "time": 0.7666, "angle": -3.56 }, - { "time": 0.9333, "angle": 1.86 }, - { "time": 1.0666, "angle": 16.02 }, - { "time": 1.3666, "angle": 1.08 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "torso": { - "rotate": [ - { "time": 0, "angle": -13.35 }, - { "time": 0.2333, "angle": -48.95 }, - { "time": 0.4333, "angle": -35.77 }, - { "time": 0.6, "angle": -4.59 }, - { "time": 0.7666, "angle": 14.61 }, - { "time": 0.9333, "angle": 15.74 }, - { "time": 1.0666, "angle": -32.43 }, - { "time": 1.3666, "angle": -13.35 } - ], - "translate": [ - { "time": 0, "x": -3.67, "y": 1.68, "curve": "stepped" }, - { "time": 0.9333, "x": -3.67, "y": 1.68, "curve": "stepped" }, - { "time": 1.3666, "x": -3.67, "y": 1.68 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "neck": { - "rotate": [ - { "time": 0, "angle": 12.78 }, - { "time": 0.2333, "angle": 16.45 }, - { "time": 0.4, "angle": 26.49 }, - { "time": 0.6, "angle": 15.51 }, - { "time": 0.7666, "angle": 1.34 }, - { "time": 0.9333, "angle": 2.34 }, - { "time": 1.0666, "angle": 6.08 }, - { "time": 1.3, "angle": 21.23 }, - { "time": 1.3666, "angle": 12.78 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "head": { - "rotate": [ - { "time": 0, "angle": 5.19 }, - { "time": 0.2333, "angle": 20.27 }, - { "time": 0.4, "angle": 15.27 }, - { "time": 0.6, "angle": -24.69 }, - { "time": 0.7666, "angle": -11.02 }, - { "time": 0.9333, "angle": -24.38 }, - { "time": 1.0666, "angle": 11.99 }, - { "time": 1.3, "angle": 4.86 }, - { "time": 1.3666, "angle": 5.19 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "left shoulder": { - "rotate": [ - { "time": 0, "angle": 0.05 }, - { "time": 0.2333, "angle": 279.66 }, - { "time": 0.5, "angle": 62.27 }, - { "time": 0.9333, "angle": 28.91 }, - { "time": 1.0666, "angle": -8.62 }, - { "time": 1.1666, "angle": -18.43 }, - { "time": 1.3666, "angle": 0.05 } - ], - "translate": [ - { "time": 0, "x": -1.76, "y": 0.56, "curve": "stepped" }, - { "time": 0.9333, "x": -1.76, "y": 0.56, "curve": "stepped" }, - { "time": 1.3666, "x": -1.76, "y": 0.56 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "left hand": { - "rotate": [ - { "time": 0, "angle": 11.58, "curve": "stepped" }, - { "time": 0.9333, "angle": 11.58, "curve": "stepped" }, - { "time": 1.3666, "angle": 11.58 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "left arm": { - "rotate": [ - { "time": 0, "angle": 0.51 }, - { "time": 0.4333, "angle": 12.82 }, - { "time": 0.6, "angle": 47.55 }, - { "time": 0.9333, "angle": 12.82 }, - { "time": 1.1666, "angle": -6.5 }, - { "time": 1.3666, "angle": 0.51 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "right shoulder": { - "rotate": [ - { "time": 0, "angle": 43.82 }, - { "time": 0.2333, "angle": -8.74 }, - { "time": 0.5333, "angle": -208.02 }, - { "time": 0.9333, "angle": -246.72 }, - { "time": 1.0666, "angle": -307.13 }, - { "time": 1.1666, "angle": 37.15 }, - { "time": 1.3666, "angle": 43.82 } - ], - "translate": [ - { "time": 0, "x": -7.84, "y": 7.19, "curve": "stepped" }, - { "time": 0.9333, "x": -7.84, "y": 7.19, "curve": "stepped" }, - { "time": 1.3666, "x": -7.84, "y": 7.19 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "right arm": { - "rotate": [ - { "time": 0, "angle": -4.02 }, - { "time": 0.6, "angle": 17.5 }, - { "time": 0.9333, "angle": -4.02 }, - { "time": 1.1666, "angle": -16.71 }, - { "time": 1.3666, "angle": -4.02 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "right hand": { - "rotate": [ - { "time": 0, "angle": 22.92, "curve": "stepped" }, - { "time": 0.9333, "angle": 22.92, "curve": "stepped" }, - { "time": 1.3666, "angle": 22.92 } - ], - "translate": [ - { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" }, - { "time": 1.3666, "x": 0, "y": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - }, - "root": { - "rotate": [ - { "time": 0, "angle": 0 }, - { "time": 0.4333, "angle": -14.52 }, - { "time": 0.8, "angle": 9.85 }, - { "time": 1.3666, "angle": 0 } - ], - "scale": [ - { "time": 0, "x": 1, "y": 1, "curve": "stepped" }, - { "time": 1.3666, "x": 1, "y": 1 } - ] - } -} -} \ No newline at end of file diff --git a/spine-cocos2dx/example/Resources/common/spineboy-skeleton.json b/spine-cocos2dx/example/Resources/common/spineboy-skeleton.json index 41acd6d28..e6df6f99a 100644 --- a/spine-cocos2dx/example/Resources/common/spineboy-skeleton.json +++ b/spine-cocos2dx/example/Resources/common/spineboy-skeleton.json @@ -1,7 +1,7 @@ { "bones": [ - { "name": "root" }, - { "name": "hip", "parent": "root", "x": 0.64, "y": 114.41 }, + { "name": "root", "length": 0 }, + { "name": "hip", "parent": "root", "length": 0, "x": 0.64, "y": 114.41 }, { "name": "left upper leg", "parent": "hip", "length": 50.39, "x": 14.45, "y": 2.81, "rotation": -89.09 }, { "name": "left lower leg", "parent": "left upper leg", "length": 56.45, "x": 51.78, "y": 3.46, "rotation": -16.65 }, { "name": "left foot", "parent": "left lower leg", "length": 46.5, "x": 64.02, "y": -8.67, "rotation": 102.43 }, @@ -15,15 +15,16 @@ { "name": "right arm", "parent": "right shoulder", "length": 36.74, "x": 49.95, "y": -0.12, "rotation": 40.12 }, { "name": "right hand", "parent": "right arm", "length": 15.32, "x": 36.9, "y": 0.34, "rotation": 2.35 }, { "name": "left shoulder", "parent": "torso", "length": 44.19, "x": 78.96, "y": -15.75, "rotation": -156.96 }, - { "name": "left arm", "parent": "left shoulder", "length": 35.62, "x": 44.19, "y": -0.01, "rotation": 44.77 }, + { "name": "left arm", "parent": "left shoulder", "length": 35.62, "x": 44.19, "y": -0.01, "rotation": 28.16 }, { "name": "left hand", "parent": "left arm", "length": 11.52, "x": 35.62, "y": 0.07, "rotation": 2.7 }, - { "name": "pelvis", "parent": "hip", "x": 1.41, "y": -6.57 } + { "name": "pelvis", "parent": "hip", "length": 0, "x": 1.41, "y": -6.57 } ], "slots": [ + { "name": "template", "bone": "root", "color": "ff898c86" }, { "name": "left shoulder", "bone": "left shoulder", "attachment": "left-shoulder" }, { "name": "left arm", "bone": "left arm", "attachment": "left-arm" }, - { "name": "left foot", "bone": "left foot", "attachment": "left-foot" }, { "name": "left hand", "bone": "left hand", "attachment": "left-hand" }, + { "name": "left foot", "bone": "left foot", "attachment": "left-foot" }, { "name": "left lower leg", "bone": "left lower leg", "attachment": "left-lower-leg" }, { "name": "left upper leg", "bone": "left upper leg", "attachment": "left-upper-leg" }, { "name": "pelvis", "bone": "pelvis", "attachment": "pelvis" }, @@ -36,8 +37,7 @@ { "name": "eyes", "bone": "head", "attachment": "eyes" }, { "name": "right shoulder", "bone": "right shoulder", "attachment": "right-shoulder" }, { "name": "right arm", "bone": "right arm", "attachment": "right-arm" }, - { "name": "right hand", "bone": "right hand", "attachment": "right-hand" }, - { "name": "left hand item", "bone": "left hand" } + { "name": "right hand", "bone": "right hand", "attachment": "right-hand" } ], "skins": { "default": { @@ -47,12 +47,12 @@ "left arm": { "left-arm": { "x": 15.11, "y": -0.44, "rotation": 33.84, "width": 35, "height": 29 } }, - "left foot": { - "left-foot": { "x": 24.35, "y": 8.88, "rotation": 3.32, "width": 65, "height": 30 } - }, "left hand": { "left-hand": { "x": 0.75, "y": 1.86, "rotation": 31.14, "width": 35, "height": 38 } }, + "left foot": { + "left-foot": { "x": 24.35, "y": 8.88, "rotation": 3.32, "width": 65, "height": 30 } + }, "left lower leg": { "left-lower-leg": { "x": 24.55, "y": -1.92, "rotation": 105.75, "width": 49, "height": 64 } }, @@ -92,9 +92,6 @@ }, "right hand": { "right-hand": { "x": 6.82, "y": 1.25, "rotation": 91.96, "width": 32, "height": 32 } - }, - "left hand item": { - "bow": { "x": -20.35, "y": 9.68, "rotation": 4.85, "width": 65, "height": 261 } } } } diff --git a/spine-cocos2dx/example/Resources/iphone-retina/spineboy.txt b/spine-cocos2dx/example/Resources/iphone-retina/spineboy.atlas similarity index 70% rename from spine-cocos2dx/example/Resources/iphone-retina/spineboy.txt rename to spine-cocos2dx/example/Resources/iphone-retina/spineboy.atlas index 5c0da8511..88fb3e0b5 100644 --- a/spine-cocos2dx/example/Resources/iphone-retina/spineboy.txt +++ b/spine-cocos2dx/example/Resources/iphone-retina/spineboy.atlas @@ -1,171 +1,165 @@ + spineboy.png format: RGBA8888 -filter: Linear,Linear +filter: Nearest,Nearest repeat: none -left-ankle - rotate: false - xy: 67, 644 - size: 25, 32 - orig: 25, 32 - offset: 0, 0 - index: -1 -left-lower-leg - rotate: false - xy: 74, 208 - size: 49, 64 - orig: 49, 64 - offset: 0, 0 - index: -1 -left-pant-bottom - rotate: false - xy: 69, 567 - size: 44, 22 - orig: 44, 22 - offset: 0, 0 - index: -1 -right-shoulder - rotate: false - xy: 71, 274 - size: 52, 51 - orig: 52, 51 - offset: 0, 0 - index: -1 -right-ankle - rotate: false - xy: 94, 628 - size: 25, 30 - orig: 25, 30 - offset: 0, 0 - index: -1 -right-pant-bottom - rotate: false - xy: 69, 524 - size: 46, 18 - orig: 46, 18 - offset: 0, 0 - index: -1 head rotate: false - xy: 2, 2 + xy: 1, 122 size: 121, 132 orig: 121, 132 offset: 0, 0 index: -1 -eyes - rotate: true - xy: 96, 136 - size: 27, 34 - orig: 34, 27 - offset: 0, 0 - index: -1 -eyes-closed - rotate: true - xy: 96, 172 - size: 27, 34 - orig: 34, 27 - offset: 0, 0 - index: -1 torso - rotate: true - xy: 2, 136 - size: 92, 68 + rotate: false + xy: 1, 28 + size: 68, 92 orig: 68, 92 offset: 0, 0 index: -1 +left-pant-bottom + rotate: false + xy: 1, 4 + size: 44, 22 + orig: 44, 22 + offset: 0, 0 + index: -1 +right-pant-bottom + rotate: false + xy: 47, 8 + size: 46, 18 + orig: 46, 18 + offset: 0, 0 + index: -1 +right-upper-leg + rotate: false + xy: 71, 50 + size: 44, 70 + orig: 44, 70 + offset: 0, 0 + index: -1 +pelvis + rotate: false + xy: 95, 1 + size: 63, 47 + orig: 63, 47 + offset: 0, 0 + index: -1 +left-upper-leg + rotate: false + xy: 117, 53 + size: 33, 67 + orig: 33, 67 + offset: 0, 0 + index: -1 +right-foot + rotate: false + xy: 160, 224 + size: 67, 30 + orig: 67, 30 + offset: 0, 0 + index: -1 +left-shoulder + rotate: false + xy: 124, 201 + size: 34, 53 + orig: 34, 53 + offset: 0, 0 + index: -1 +left-ankle + rotate: false + xy: 229, 222 + size: 25, 32 + orig: 25, 32 + offset: 0, 0 + index: -1 left-foot rotate: false - xy: 2, 582 + xy: 160, 192 size: 65, 30 orig: 65, 30 offset: 0, 0 index: -1 neck rotate: false - xy: 33, 614 + xy: 124, 171 size: 34, 28 orig: 34, 28 offset: 0, 0 index: -1 -right-foot - rotate: false - xy: 2, 287 - size: 67, 30 - orig: 67, 30 - offset: 0, 0 - index: -1 -left-shoulder - rotate: true - xy: 69, 327 - size: 53, 34 - orig: 34, 53 - offset: 0, 0 - index: -1 -right-upper-leg - rotate: true - xy: 2, 206 - size: 70, 44 - orig: 44, 70 - offset: 0, 0 - index: -1 -left-arm - rotate: true - xy: 2, 628 - size: 29, 35 - orig: 35, 29 - offset: 0, 0 - index: -1 -left-hand - rotate: true - xy: 69, 591 - size: 38, 35 - orig: 35, 38 - offset: 0, 0 - index: -1 -bow - rotate: false - xy: 2, 319 - size: 65, 261 - orig: 65, 261 - offset: 0, 0 - index: -1 right-arm - rotate: true - xy: 69, 544 - size: 45, 21 + rotate: false + xy: 124, 124 + size: 21, 45 orig: 21, 45 offset: 0, 0 index: -1 -right-foot-idle +right-ankle rotate: false - xy: 69, 363 - size: 53, 28 - orig: 53, 28 + xy: 227, 190 + size: 25, 30 + orig: 25, 30 + offset: 0, 0 + index: -1 +left-hand + rotate: false + xy: 147, 131 + size: 35, 38 + orig: 35, 38 + offset: 0, 0 + index: -1 +left-arm + rotate: false + xy: 184, 161 + size: 35, 29 + orig: 35, 29 + offset: 0, 0 + index: -1 +eyes-closed + rotate: false + xy: 221, 161 + size: 34, 27 + orig: 34, 27 offset: 0, 0 index: -1 right-lower-leg rotate: false - xy: 69, 393 + xy: 152, 65 size: 51, 64 orig: 51, 64 offset: 0, 0 index: -1 -pelvis - rotate: true - xy: 69, 459 - size: 47, 63 - orig: 63, 47 +right-foot-idle + rotate: false + xy: 184, 131 + size: 53, 28 + orig: 53, 28 offset: 0, 0 index: -1 -left-upper-leg - rotate: true - xy: 2, 252 - size: 67, 33 - orig: 33, 67 +left-lower-leg + rotate: false + xy: 205, 65 + size: 49, 64 + orig: 49, 64 + offset: 0, 0 + index: -1 +right-shoulder + rotate: false + xy: 160, 12 + size: 52, 51 + orig: 52, 51 + offset: 0, 0 + index: -1 +eyes + rotate: false + xy: 214, 36 + size: 34, 27 + orig: 34, 27 offset: 0, 0 index: -1 right-hand rotate: false - xy: 33, 644 + xy: 214, 2 size: 32, 32 orig: 32, 32 offset: 0, 0 diff --git a/spine-cocos2dx/example/Resources/iphone-retina/spineboy.png b/spine-cocos2dx/example/Resources/iphone-retina/spineboy.png index 3efcfccee..b8b493dfd 100644 Binary files a/spine-cocos2dx/example/Resources/iphone-retina/spineboy.png and b/spine-cocos2dx/example/Resources/iphone-retina/spineboy.png differ diff --git a/spine-cocos2dx/example/Resources/iphone/spineboy.atlas b/spine-cocos2dx/example/Resources/iphone/spineboy.atlas new file mode 100644 index 000000000..88fb3e0b5 --- /dev/null +++ b/spine-cocos2dx/example/Resources/iphone/spineboy.atlas @@ -0,0 +1,166 @@ + +spineboy.png +format: RGBA8888 +filter: Nearest,Nearest +repeat: none +head + rotate: false + xy: 1, 122 + size: 121, 132 + orig: 121, 132 + offset: 0, 0 + index: -1 +torso + rotate: false + xy: 1, 28 + size: 68, 92 + orig: 68, 92 + offset: 0, 0 + index: -1 +left-pant-bottom + rotate: false + xy: 1, 4 + size: 44, 22 + orig: 44, 22 + offset: 0, 0 + index: -1 +right-pant-bottom + rotate: false + xy: 47, 8 + size: 46, 18 + orig: 46, 18 + offset: 0, 0 + index: -1 +right-upper-leg + rotate: false + xy: 71, 50 + size: 44, 70 + orig: 44, 70 + offset: 0, 0 + index: -1 +pelvis + rotate: false + xy: 95, 1 + size: 63, 47 + orig: 63, 47 + offset: 0, 0 + index: -1 +left-upper-leg + rotate: false + xy: 117, 53 + size: 33, 67 + orig: 33, 67 + offset: 0, 0 + index: -1 +right-foot + rotate: false + xy: 160, 224 + size: 67, 30 + orig: 67, 30 + offset: 0, 0 + index: -1 +left-shoulder + rotate: false + xy: 124, 201 + size: 34, 53 + orig: 34, 53 + offset: 0, 0 + index: -1 +left-ankle + rotate: false + xy: 229, 222 + size: 25, 32 + orig: 25, 32 + offset: 0, 0 + index: -1 +left-foot + rotate: false + xy: 160, 192 + size: 65, 30 + orig: 65, 30 + offset: 0, 0 + index: -1 +neck + rotate: false + xy: 124, 171 + size: 34, 28 + orig: 34, 28 + offset: 0, 0 + index: -1 +right-arm + rotate: false + xy: 124, 124 + size: 21, 45 + orig: 21, 45 + offset: 0, 0 + index: -1 +right-ankle + rotate: false + xy: 227, 190 + size: 25, 30 + orig: 25, 30 + offset: 0, 0 + index: -1 +left-hand + rotate: false + xy: 147, 131 + size: 35, 38 + orig: 35, 38 + offset: 0, 0 + index: -1 +left-arm + rotate: false + xy: 184, 161 + size: 35, 29 + orig: 35, 29 + offset: 0, 0 + index: -1 +eyes-closed + rotate: false + xy: 221, 161 + size: 34, 27 + orig: 34, 27 + offset: 0, 0 + index: -1 +right-lower-leg + rotate: false + xy: 152, 65 + size: 51, 64 + orig: 51, 64 + offset: 0, 0 + index: -1 +right-foot-idle + rotate: false + xy: 184, 131 + size: 53, 28 + orig: 53, 28 + offset: 0, 0 + index: -1 +left-lower-leg + rotate: false + xy: 205, 65 + size: 49, 64 + orig: 49, 64 + offset: 0, 0 + index: -1 +right-shoulder + rotate: false + xy: 160, 12 + size: 52, 51 + orig: 52, 51 + offset: 0, 0 + index: -1 +eyes + rotate: false + xy: 214, 36 + size: 34, 27 + orig: 34, 27 + offset: 0, 0 + index: -1 +right-hand + rotate: false + xy: 214, 2 + size: 32, 32 + orig: 32, 32 + offset: 0, 0 + index: -1 diff --git a/spine-cocos2dx/example/Resources/iphone/spineboy.png b/spine-cocos2dx/example/Resources/iphone/spineboy.png index c43543727..b8b493dfd 100644 Binary files a/spine-cocos2dx/example/Resources/iphone/spineboy.png and b/spine-cocos2dx/example/Resources/iphone/spineboy.png differ diff --git a/spine-cocos2dx/example/Resources/iphone/spineboy.txt b/spine-cocos2dx/example/Resources/iphone/spineboy.txt deleted file mode 100644 index 7be5a2100..000000000 --- a/spine-cocos2dx/example/Resources/iphone/spineboy.txt +++ /dev/null @@ -1,172 +0,0 @@ -spineboy.png -format: RGBA8888 -filter: Linear,Linear -repeat: none -left-ankle - rotate: true - xy: 168, 92 - size: 16, 13 - orig: 13, 16 - offset: 0, 0 - index: -1 -left-lower-leg - rotate: false - xy: 101, 37 - size: 25, 32 - orig: 25, 32 - offset: 0, 0 - index: -1 -left-pant-bottom - rotate: false - xy: 152, 61 - size: 22, 11 - orig: 22, 11 - offset: 0, 0 - index: -1 -right-shoulder - rotate: false - xy: 127, 74 - size: 26, 26 - orig: 26, 26 - offset: 0, 0 - index: -1 -right-ankle - rotate: false - xy: 148, 107 - size: 13, 15 - orig: 13, 15 - offset: 0, 0 - index: -1 -right-pant-bottom - rotate: true - xy: 152, 36 - size: 9, 23 - orig: 23, 9 - offset: 0, 0 - index: -1 -head - rotate: false - xy: 2, 37 - size: 61, 66 - orig: 61, 66 - offset: 0, 0 - index: -1 -eyes - rotate: true - xy: 112, 105 - size: 14, 17 - orig: 17, 14 - offset: 0, 0 - index: -1 -eyes-closed - rotate: false - xy: 163, 107 - size: 17, 14 - orig: 17, 14 - offset: 0, 0 - index: -1 -torso - rotate: false - xy: 65, 37 - size: 34, 46 - orig: 34, 46 - offset: 0, 0 - index: -1 -left-foot - rotate: true - xy: 163, 2 - size: 15, 33 - orig: 33, 15 - offset: 0, 0 - index: -1 -neck - rotate: true - xy: 96, 105 - size: 14, 17 - orig: 17, 14 - offset: 0, 0 - index: -1 -right-foot - rotate: false - xy: 65, 85 - size: 34, 15 - orig: 34, 15 - offset: 0, 0 - index: -1 -left-shoulder - rotate: true - xy: 38, 105 - size: 27, 17 - orig: 17, 27 - offset: 0, 0 - index: -1 -right-upper-leg - rotate: false - xy: 128, 37 - size: 22, 35 - orig: 22, 35 - offset: 0, 0 - index: -1 -left-arm - rotate: true - xy: 163, 37 - size: 15, 18 - orig: 18, 15 - offset: 0, 0 - index: -1 -left-hand - rotate: false - xy: 128, 102 - size: 18, 19 - orig: 18, 19 - offset: 0, 0 - index: -1 -bow - rotate: true - xy: 2, 2 - size: 131, 33 - orig: 33, 131 - offset: 0, 0 - index: -1 -right-arm - rotate: false - xy: 155, 74 - size: 11, 23 - orig: 11, 23 - offset: 0, 0 - index: -1 -right-foot-idle - rotate: false - xy: 67, 102 - size: 27, 14 - orig: 27, 14 - offset: 0, 0 - index: -1 -right-lower-leg - rotate: false - xy: 135, 2 - size: 26, 32 - orig: 26, 32 - offset: 0, 0 - index: -1 -pelvis - rotate: true - xy: 101, 71 - size: 24, 32 - orig: 32, 24 - offset: 0, 0 - index: -1 -left-upper-leg - rotate: true - xy: 2, 105 - size: 34, 17 - orig: 17, 34 - offset: 0, 0 - index: -1 -right-hand - rotate: false - xy: 168, 74 - size: 16, 16 - orig: 16, 16 - offset: 0, 0 - index: -1 diff --git a/spine-cocos2dx/example/proj.win32/spine-cocos2dx.vcxproj b/spine-cocos2dx/example/proj.win32/spine-cocos2dx.vcxproj index 7de53a3ed..2754577f1 100644 --- a/spine-cocos2dx/example/proj.win32/spine-cocos2dx.vcxproj +++ b/spine-cocos2dx/example/proj.win32/spine-cocos2dx.vcxproj @@ -66,7 +66,7 @@ Disabled - $(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\Classes;$(ProjectDir)..\..\include;$(ProjectDir)..\..\..\spine-cpp\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\Classes;$(ProjectDir)..\..\src;$(ProjectDir)..\..\..\spine-c\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -76,6 +76,7 @@ Level3 EditAndContinue 4267;4251;4244;%(DisableSpecificWarnings) + CompileAsCpp opengl32.lib;glew32.lib;libcocos2d.lib;%(AdditionalDependencies) @@ -123,65 +124,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -191,11 +178,6 @@ {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} - - - - - diff --git a/spine-cocos2dx/example/proj.win32/spine-cocos2dx.vcxproj.filters b/spine-cocos2dx/example/proj.win32/spine-cocos2dx.vcxproj.filters index 9ff024dba..afab79138 100644 --- a/spine-cocos2dx/example/proj.win32/spine-cocos2dx.vcxproj.filters +++ b/spine-cocos2dx/example/proj.win32/spine-cocos2dx.vcxproj.filters @@ -7,18 +7,12 @@ {0dcd52ca-d521-4ba1-a1fa-c0d58a2df402} - - {bce9df76-2682-4d32-a178-779e330d0ff1} - - - {b04a4c76-3e5e-4539-8872-da087cfb695b} - - - {35486b88-a772-4ecb-9c30-e6c2a21a4734} - {7c460e6e-d4fb-452e-b75f-7a110b9dd9f6} + + {bce9df76-2682-4d32-a178-779e330d0ff1} + @@ -30,102 +24,69 @@ Classes - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\json - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - Classes + + Classes\spine-cocos2dx + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + @@ -134,85 +95,65 @@ Classes - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\spine - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - - - Classes\spine-cocos2dx - Classes - - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - - - Classes\spine-cpp\json - + + Classes\spine-cocos2dx + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + + + Classes\spine-c + \ No newline at end of file diff --git a/spine-cocos2dx/include/spine-cocos2dx/Atlas.h b/spine-cocos2dx/include/spine-cocos2dx/Atlas.h deleted file mode 100644 index 755a817ef..000000000 --- a/spine-cocos2dx/include/spine-cocos2dx/Atlas.h +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#ifndef SPINE_ATLAS_H_ -#define SPINE_ATLAS_H_ - -#include "cocos2d.h" -#include - -namespace spine { - -class AtlasPage: public BaseAtlasPage { -public: - ~AtlasPage (); - - cocos2d::CCTexture2D *texture; - cocos2d::CCTextureAtlas *atlas; -}; - -// - -class AtlasRegion: public BaseAtlasRegion { -public: - AtlasPage *page; -}; - -// - -class Atlas: public BaseAtlas { -public: - Atlas (const std::string &path); - Atlas (std::istream &input); - Atlas (const char *begin, const char *end); - - AtlasRegion* findRegion (const std::string &name); - -private: - virtual BaseAtlasPage* newAtlasPage (const std::string &name); - virtual BaseAtlasRegion* newAtlasRegion (BaseAtlasPage* page); -}; - -} /* namespace spine */ -#endif /* SPINE_ATLAS_H_ */ diff --git a/spine-cocos2dx/include/spine-cocos2dx/AtlasAttachmentLoader.h b/spine-cocos2dx/include/spine-cocos2dx/AtlasAttachmentLoader.h deleted file mode 100644 index 3257b0986..000000000 --- a/spine-cocos2dx/include/spine-cocos2dx/AtlasAttachmentLoader.h +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#ifndef SPINE_ATLASATTACHMENTLOADER_H_ -#define SPINE_ATLASATTACHMENTLOADER_H_ - -#include - -namespace spine { - -class Atlas; - -class AtlasAttachmentLoader: public BaseAttachmentLoader { -public: - Atlas *atlas; - - AtlasAttachmentLoader (Atlas *atlas); - - virtual Attachment* newAttachment (AttachmentType type, const std::string &name); -}; - -} /* namespace spine */ -#endif /* SPINE_ATLASATTACHMENTLOADER_H_ */ diff --git a/spine-cocos2dx/include/spine-cocos2dx/RegionAttachment.h b/spine-cocos2dx/include/spine-cocos2dx/RegionAttachment.h deleted file mode 100644 index ac87dd988..000000000 --- a/spine-cocos2dx/include/spine-cocos2dx/RegionAttachment.h +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#ifndef SPINE_REGIONATTACHMENT_H_ -#define SPINE_REGIONATTACHMENT_H_ - -#include "cocos2d.h" -#include - -namespace spine { - -class Bone; -class AtlasRegion; - -class RegionAttachment: public BaseRegionAttachment { -public: - cocos2d::ccV3F_C4B_T2F_Quad quad; - cocos2d::CCTextureAtlas *atlas; - - RegionAttachment (AtlasRegion *region); - - virtual void updateWorldVertices (Bone *bone); - virtual void draw (Slot *slot); -}; - -} /* namespace spine */ -#endif /* SPINE_REGIONATTACHMENT_H_ */ diff --git a/spine-cocos2dx/include/spine-cocos2dx/Skeleton.h b/spine-cocos2dx/include/spine-cocos2dx/Skeleton.h deleted file mode 100644 index 89d83fb25..000000000 --- a/spine-cocos2dx/include/spine-cocos2dx/Skeleton.h +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#ifndef SPINE_SKELETON_H_ -#define SPINE_SKELETON_H_ - -#include "cocos2d.h" -#include - -namespace spine { - -class Skeleton: public BaseSkeleton { -private: - unsigned int quadCount; - -public: - cocos2d::CCTextureAtlas *atlas; // All region attachments must use the same texture. - - Skeleton (SkeletonData *skeletonData); - - void addQuad (cocos2d::CCTextureAtlas *atlas, cocos2d::ccV3F_C4B_T2F_Quad &quad); - virtual void draw (); -}; - -} /* namespace spine */ -#endif /* SPINE_SKELETON_H_ */ diff --git a/spine-cocos2dx/include/spine-cocos2dx/SkeletonJson.h b/spine-cocos2dx/include/spine-cocos2dx/SkeletonJson.h deleted file mode 100644 index 576d2c55c..000000000 --- a/spine-cocos2dx/include/spine-cocos2dx/SkeletonJson.h +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#ifndef SPINE_SKELETONJSON_H_ -#define SPINE_SKELETONJSON_H_ - -#include - -namespace spine { - -class Atlas; - -class SkeletonJson: public BaseSkeletonJson { -public: - SkeletonJson (Atlas *atlas); - /** The SkeletonJson owns the attachmentLoader. */ - SkeletonJson (BaseAttachmentLoader *attachmentLoader); - - SkeletonData* readSkeletonData (const std::string &path) const; - Animation* readAnimation (const std::string &path, const SkeletonData *skeletonData) const; -}; - -} /* namespace spine */ -#endif /* SPINE_SKELETONJSON_H_ */ diff --git a/spine-cocos2dx/include/spine-cocos2dx/spine.h b/spine-cocos2dx/include/spine-cocos2dx/spine.h deleted file mode 100644 index b0a830f18..000000000 --- a/spine-cocos2dx/include/spine-cocos2dx/spine.h +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#ifndef SPINE_SPINE_H_ -#define SPINE_SPINE_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#endif /* SF_SPINE_H_ */ diff --git a/spine-cocos2dx/src/spine-cocos2dx/Atlas.cpp b/spine-cocos2dx/src/spine-cocos2dx/Atlas.cpp deleted file mode 100644 index bb8638290..000000000 --- a/spine-cocos2dx/src/spine-cocos2dx/Atlas.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#include -#include - -USING_NS_CC; - -namespace spine { - -AtlasPage::~AtlasPage () { - CC_SAFE_RELEASE_NULL(texture); - CC_SAFE_RELEASE_NULL(atlas); -} - -// - -Atlas::Atlas (const std::string &path) { - unsigned long size; - char *data = reinterpret_cast(CCFileUtils::sharedFileUtils()->getFileData( - CCFileUtils::sharedFileUtils()->fullPathForFilename(path.c_str()).c_str(), "r", &size)); - if (!data) throw std::runtime_error("Error reading atlas file: " + path); - load(data, data + size); -} - -Atlas::Atlas (std::istream &input) { - load(input); -} - -Atlas::Atlas (const char *begin, const char *end) { - load(begin, end); -} - -BaseAtlasPage* Atlas::newAtlasPage (const std::string &name) { - AtlasPage *page = new AtlasPage(); - page->texture = CCTextureCache::sharedTextureCache()->addImage(name.c_str()); - page->texture->retain(); - page->atlas = CCTextureAtlas::createWithTexture(page->texture, 4); - page->atlas->retain(); - return page; -} - -BaseAtlasRegion* Atlas::newAtlasRegion (BaseAtlasPage* page) { - AtlasRegion *region = new AtlasRegion(); - region->page = reinterpret_cast(page); - return region; -} - -AtlasRegion* Atlas::findRegion (const std::string &name) { - return reinterpret_cast(BaseAtlas::findRegion(name)); -} - -} /* namespace spine */ diff --git a/spine-cocos2dx/src/spine-cocos2dx/AtlasAttachmentLoader.cpp b/spine-cocos2dx/src/spine-cocos2dx/AtlasAttachmentLoader.cpp deleted file mode 100644 index 185ad1430..000000000 --- a/spine-cocos2dx/src/spine-cocos2dx/AtlasAttachmentLoader.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#include -#include -#include -#include - -namespace spine { - -AtlasAttachmentLoader::AtlasAttachmentLoader (Atlas *atlas) : - atlas(atlas) { -} - -Attachment* AtlasAttachmentLoader::newAttachment (AttachmentType type, const std::string &name) { - switch (type) { - case region: { - AtlasRegion *region = atlas->findRegion(name); - if (!region) throw std::runtime_error("Atlas region not found: " + name); - return new RegionAttachment(region); - } - default: - throw std::runtime_error("Unknown attachment type: " + type); - } -} - -} /* namespace spine */ diff --git a/spine-cocos2dx/src/spine-cocos2dx/CCSkeleton.cpp b/spine-cocos2dx/src/spine-cocos2dx/CCSkeleton.cpp deleted file mode 100644 index 2ac3a8f6c..000000000 --- a/spine-cocos2dx/src/spine-cocos2dx/CCSkeleton.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace spine; -USING_NS_CC; - -CCSkeleton* CCSkeleton::create (SkeletonData* skeletonData) { - CCSkeleton* skeleton = new CCSkeleton(skeletonData); - skeleton->autorelease(); - return skeleton; -} - -CCSkeleton::CCSkeleton (SkeletonData *skeletonData, AnimationStateData *stateData) : - debug(false) { - if (!skeletonData) throw std::invalid_argument("skeletonData cannot be null."); - skeleton = new Skeleton(skeletonData); - state = new AnimationState(stateData); - - blendFunc.src = GL_SRC_ALPHA; - blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; - - setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor)); - scheduleUpdate(); -} - -CCSkeleton::~CCSkeleton () { - delete skeleton; - delete state; -} - -void CCSkeleton::update (float deltaTime) { - skeleton->update(deltaTime); - state->update(deltaTime); - state->apply(skeleton); - skeleton->updateWorldTransform(); -} - -void CCSkeleton::draw () { - CC_NODE_DRAW_SETUP(); - - ccGLBlendFunc(blendFunc.src, blendFunc.dst); - ccColor3B color = getColor(); - skeleton->r = color.r / (float)255; - skeleton->g = color.g / (float)255; - skeleton->b = color.b / (float)255; - skeleton->a = getOpacity() / (float)255; - skeleton->draw(); - - if (debug) { - // Slots. - ccDrawColor4B(0, 0, 255, 10); - glLineWidth(1); - CCPoint points[4]; - for (int i = 0, n = skeleton->slots.size(); i < n; i++) { - if (!skeleton->slots[i]->attachment) continue; - ccV3F_C4B_T2F_Quad quad = ((RegionAttachment*)skeleton->slots[i]->attachment)->quad; - points[0] = ccp(quad.bl.vertices.x, quad.bl.vertices.y); - points[1] = ccp(quad.br.vertices.x, quad.br.vertices.y); - points[2] = ccp(quad.tr.vertices.x, quad.tr.vertices.y); - points[3] = ccp(quad.tl.vertices.x, quad.tl.vertices.y); - ccDrawPoly(points, 4, true); - } - // Bone lengths. - glLineWidth(2); - ccDrawColor4B(255, 0, 0, 255); - for (int i = 0, n = skeleton->bones.size(); i < n; i++) { - Bone *bone = skeleton->bones[i]; - float x = bone->data->length * bone->m00 + bone->worldX; - float y = bone->data->length * bone->m10 + bone->worldY; - ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y)); - } - // Bone origins. - ccPointSize(4); - ccDrawColor4B(0, 0, 255, 255); // Root bone is blue. - for (int i = 0, n = skeleton->bones.size(); i < n; i++) { - Bone *bone = skeleton->bones[i]; - ccDrawPoint(ccp(bone->worldX, bone->worldY)); - if (i == 0) ccDrawColor4B(0, 255, 0, 255); - } - } -} - -// CCBlendProtocol - -ccBlendFunc CCSkeleton::getBlendFunc () { - return blendFunc; -} - -void CCSkeleton::setBlendFunc (ccBlendFunc blendFunc) { - this->blendFunc = blendFunc; -} diff --git a/spine-cocos2dx/src/spine-cocos2dx/RegionAttachment.cpp b/spine-cocos2dx/src/spine-cocos2dx/RegionAttachment.cpp deleted file mode 100644 index 9fa483d2f..000000000 --- a/spine-cocos2dx/src/spine-cocos2dx/RegionAttachment.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#include -#include -#include -#include -#include -#include - -USING_NS_CC; - -namespace spine { - -RegionAttachment::RegionAttachment (AtlasRegion *region) { - atlas = region->page->atlas; - const CCSize &size = region->page->texture->getContentSizeInPixels(); - float u = region->x / size.width; - float u2 = (region->x + region->width) / size.width; - float v = region->y / size.height; - float v2 = (region->y + region->height) / size.height; - if (region->rotate) { - quad.tl.texCoords.u = u; - quad.tl.texCoords.v = v2; - quad.tr.texCoords.u = u; - quad.tr.texCoords.v = v; - quad.br.texCoords.u = u2; - quad.br.texCoords.v = v; - quad.bl.texCoords.u = u2; - quad.bl.texCoords.v = v2; - } else { - quad.bl.texCoords.u = u; - quad.bl.texCoords.v = v2; - quad.tl.texCoords.u = u; - quad.tl.texCoords.v = v; - quad.tr.texCoords.u = u2; - quad.tr.texCoords.v = v; - quad.br.texCoords.u = u2; - quad.br.texCoords.v = v2; - } - - quad.bl.vertices.z = 0; - quad.tl.vertices.z = 0; - quad.tr.vertices.z = 0; - quad.br.vertices.z = 0; -} - -void RegionAttachment::draw (Slot *slot) { - Skeleton* skeleton = (Skeleton*)slot->skeleton; - - GLubyte r = skeleton->r * slot->r * 255; - GLubyte g = skeleton->g * slot->g * 255; - GLubyte b = skeleton->b * slot->b * 255; - GLubyte a = skeleton->a * slot->a * 255; - quad.bl.colors.r = r; - quad.bl.colors.g = g; - quad.bl.colors.b = b; - quad.bl.colors.a = a; - quad.tl.colors.r = r; - quad.tl.colors.g = g; - quad.tl.colors.b = b; - quad.tl.colors.a = a; - quad.tr.colors.r = r; - quad.tr.colors.g = g; - quad.tr.colors.b = b; - quad.tr.colors.a = a; - quad.br.colors.r = r; - quad.br.colors.g = g; - quad.br.colors.b = b; - quad.br.colors.a = a; - - updateWorldVertices(slot->bone); - - // cocos2dx doesn't handle batching for us, so we'll just force a single texture per skeleton. - skeleton->addQuad(atlas, quad); -} - -void RegionAttachment::updateWorldVertices (spine::Bone *bone) { - quad.bl.vertices.x = offset[0] * bone->m00 + offset[1] * bone->m01 + bone->worldX; - quad.bl.vertices.y = offset[0] * bone->m10 + offset[1] * bone->m11 + bone->worldY; - quad.tl.vertices.x = offset[2] * bone->m00 + offset[3] * bone->m01 + bone->worldX; - quad.tl.vertices.y = offset[2] * bone->m10 + offset[3] * bone->m11 + bone->worldY; - quad.tr.vertices.x = offset[4] * bone->m00 + offset[5] * bone->m01 + bone->worldX; - quad.tr.vertices.y = offset[4] * bone->m10 + offset[5] * bone->m11 + bone->worldY; - quad.br.vertices.x = offset[6] * bone->m00 + offset[7] * bone->m01 + bone->worldX; - quad.br.vertices.y = offset[6] * bone->m10 + offset[7] * bone->m11 + bone->worldY; -} - -} /* namespace spine */ diff --git a/spine-cocos2dx/src/spine-cocos2dx/Skeleton.cpp b/spine-cocos2dx/src/spine-cocos2dx/Skeleton.cpp deleted file mode 100644 index 490b8b1a5..000000000 --- a/spine-cocos2dx/src/spine-cocos2dx/Skeleton.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#include -#include -#include -#include -#include - -USING_NS_CC; - -namespace spine { - -Skeleton::Skeleton (SkeletonData *skeletonData) : - BaseSkeleton(skeletonData), - quadCount(0), - atlas(0) { -} - -void Skeleton::addQuad (cocos2d::CCTextureAtlas *atlas, cocos2d::ccV3F_C4B_T2F_Quad &quad) { - this->atlas = atlas; - if (atlas->getCapacity() <= quadCount) { - if (!atlas->resizeCapacity(atlas->getCapacity() * 2)) return; - } - atlas->updateQuad(&quad, quadCount++); -} - -void Skeleton::draw () { - quadCount = 0; - for (int i = 0, n = slots.size(); i < n; i++) - if (slots[i]->attachment) slots[i]->attachment->draw(slots[i]); - if (atlas) atlas->drawNumberOfQuads(quadCount); -} - -} /* namespace spine */ diff --git a/spine-cocos2dx/src/spine-cocos2dx/SkeletonJson.cpp b/spine-cocos2dx/src/spine-cocos2dx/SkeletonJson.cpp deleted file mode 100644 index a41b88cfe..000000000 --- a/spine-cocos2dx/src/spine-cocos2dx/SkeletonJson.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#include -#include -#include -#include "platform/CCFileUtils.h" - -using cocos2d::CCFileUtils; -using std::runtime_error; - -namespace spine { - -SkeletonJson::SkeletonJson (BaseAttachmentLoader *attachmentLoader) : - BaseSkeletonJson(attachmentLoader) { -} - -SkeletonJson::SkeletonJson (Atlas *atlas) : - BaseSkeletonJson(new AtlasAttachmentLoader(atlas)) { -} - -SkeletonData* SkeletonJson::readSkeletonData (const std::string &path) const { - unsigned long size; - char *data = reinterpret_cast(CCFileUtils::sharedFileUtils()->getFileData( - CCFileUtils::sharedFileUtils()->fullPathForFilename(path.c_str()).c_str(), "r", &size)); - if (!data) throw runtime_error("Error reading skeleton file: " + path); - return BaseSkeletonJson::readSkeletonData(data, data + size); -} - -Animation* SkeletonJson::readAnimation (const std::string &path, const SkeletonData *skeletonData) const { - unsigned long size; - char *data = reinterpret_cast(CCFileUtils::sharedFileUtils()->getFileData( - CCFileUtils::sharedFileUtils()->fullPathForFilename(path.c_str()).c_str(), "r", &size)); - if (!data) throw runtime_error("Error reading animation file: " + path); - return BaseSkeletonJson::readAnimation(data, data + size, skeletonData); -} - -} /* namespace spine */ diff --git a/spine-cocos2dx/src/spine/spine-cocos2dx.cpp b/spine-cocos2dx/src/spine/spine-cocos2dx.cpp new file mode 100644 index 000000000..910df5162 --- /dev/null +++ b/spine-cocos2dx/src/spine/spine-cocos2dx.cpp @@ -0,0 +1,272 @@ +/******************************************************************************* + * Copyright (c) 2013, Esoteric Software + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ + +#include +#include +#include +#include "cocos2d.h" + +USING_NS_CC; +namespace spine { + +void _Cocos2dxAtlasPage_dispose (AtlasPage* page) { + Cocos2dxAtlasPage* self = SUB_CAST(Cocos2dxAtlasPage, page); + _AtlasPage_deinit(SUPER(self)); + + CC_SAFE_RELEASE_NULL(self->texture); + CC_SAFE_RELEASE_NULL(self->atlas); + + FREE(page); +} + +AtlasPage* AtlasPage_create (const char* name) { + Cocos2dxAtlasPage* self = NEW(Cocos2dxAtlasPage); + _AtlasPage_init(SUPER(self), name); + VTABLE(AtlasPage, self) ->dispose = _Cocos2dxAtlasPage_dispose; + + self->texture = CCTextureCache::sharedTextureCache()->addImage(name); + self->texture->retain(); + self->atlas = CCTextureAtlas::createWithTexture(self->texture, 4); + self->atlas->retain(); + + return SUPER(self); +} + +/**/ + +void _Cocos2dxSkeleton_dispose (Skeleton* self) { + _Skeleton_deinit(self); + FREE(self); +} + +class CCSkeleton; + +Skeleton* _Cocos2dxSkeleton_create (SkeletonData* data, CCSkeleton* node) { + Cocos2dxSkeleton* self = NEW(Cocos2dxSkeleton); + _Skeleton_init(SUPER(self), data); + VTABLE(Skeleton, self) ->dispose = _Cocos2dxSkeleton_dispose; + + self->node = node; + + return SUPER(self); +} + +CCSkeleton* CCSkeleton::create (SkeletonData* skeletonData) { + CCSkeleton* node = new CCSkeleton(skeletonData); + node->autorelease(); + return node; +} + +CCSkeleton::CCSkeleton (SkeletonData *skeletonData, AnimationStateData *stateData) : + debugSlots(false), debugBones(false) { + skeleton = _Cocos2dxSkeleton_create(skeletonData, this); + state = AnimationState_create(stateData); + + blendFunc.src = GL_ONE; + blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + + setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor)); + scheduleUpdate(); +} + +CCSkeleton::~CCSkeleton () { + Skeleton_dispose(skeleton); + AnimationState_dispose(state); +} + +void CCSkeleton::update (float deltaTime) { + Skeleton_update(skeleton, deltaTime); + AnimationState_update(state, deltaTime); + AnimationState_apply(state, skeleton); + Skeleton_updateWorldTransform(skeleton); +} + +#include + +void CCSkeleton::draw () { + CC_NODE_DRAW_SETUP(); + + ccGLBlendFunc(blendFunc.src, blendFunc.dst); + ccColor3B color = getColor(); + skeleton->r = color.r / (float)255; + skeleton->g = color.g / (float)255; + skeleton->b = color.b / (float)255; + skeleton->a = getOpacity() / (float)255; + + quadCount = 0; + for (int i = 0, n = skeleton->slotCount; i < n; i++) + if (skeleton->slots[i]->attachment) Attachment_draw(skeleton->slots[i]->attachment, skeleton->slots[i]); + if (atlas) atlas->drawNumberOfQuads(quadCount); + + if (debugSlots) { + // Slots. + ccDrawColor4B(0, 0, 255, 255); + glLineWidth(1); + CCPoint points[4]; + for (int i = 0, n = skeleton->slotCount; i < n; i++) { + if (!skeleton->slots[i]->attachment) continue; + ccV3F_C4B_T2F_Quad* quad = &((Cocos2dxRegionAttachment*)skeleton->slots[i]->attachment)->quad; + points[0] = ccp(quad->bl.vertices.x, quad->bl.vertices.y); + points[1] = ccp(quad->br.vertices.x, quad->br.vertices.y); + points[2] = ccp(quad->tr.vertices.x, quad->tr.vertices.y); + points[3] = ccp(quad->tl.vertices.x, quad->tl.vertices.y); + ccDrawPoly(points, 4, true); + } + } + if (debugBones) { + // Bone lengths. + glLineWidth(2); + ccDrawColor4B(255, 0, 0, 255); + for (int i = 0, n = skeleton->boneCount; i < n; i++) { + Bone *bone = skeleton->bones[i]; + float x = bone->data->length * bone->m00 + bone->worldX; + float y = bone->data->length * bone->m10 + bone->worldY; + ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y)); + } + // Bone origins. + ccPointSize(4); + ccDrawColor4B(0, 0, 255, 255); // Root bone is blue. + for (int i = 0, n = skeleton->boneCount; i < n; i++) { + Bone *bone = skeleton->bones[i]; + ccDrawPoint(ccp(bone->worldX, bone->worldY)); + if (i == 0) ccDrawColor4B(0, 255, 0, 255); + } + } +} + +// CCBlendProtocol + +ccBlendFunc CCSkeleton::getBlendFunc () { + return blendFunc; +} + +void CCSkeleton::setBlendFunc (ccBlendFunc blendFunc) { + this->blendFunc = blendFunc; +} + +/**/ + +void _Cocos2dxRegionAttachment_dispose (Attachment* self) { + _RegionAttachment_deinit(SUB_CAST(RegionAttachment, self) ); + FREE(self); +} + +void _Cocos2dxRegionAttachment_draw (Attachment* attachment, Slot* slot) { + Cocos2dxRegionAttachment* self = SUB_CAST(Cocos2dxRegionAttachment, attachment); + Cocos2dxSkeleton* skeleton = SUB_CAST(Cocos2dxSkeleton, slot->skeleton); + + GLubyte r = SUPER(skeleton)->r * slot->r * 255; + GLubyte g = SUPER(skeleton)->g * slot->g * 255; + GLubyte b = SUPER(skeleton)->b * slot->b * 255; + GLubyte a = SUPER(skeleton)->a * slot->a * 255; + ccV3F_C4B_T2F_Quad* quad = &self->quad; + quad->bl.colors.r = r; + quad->bl.colors.g = g; + quad->bl.colors.b = b; + quad->bl.colors.a = a; + quad->tl.colors.r = r; + quad->tl.colors.g = g; + quad->tl.colors.b = b; + quad->tl.colors.a = a; + quad->tr.colors.r = r; + quad->tr.colors.g = g; + quad->tr.colors.b = b; + quad->tr.colors.a = a; + quad->br.colors.r = r; + quad->br.colors.g = g; + quad->br.colors.b = b; + quad->br.colors.a = a; + + float* offset = SUPER(self)->offset; + quad->bl.vertices.x = offset[0] * slot->bone->m00 + offset[1] * slot->bone->m01 + slot->bone->worldX; + quad->bl.vertices.y = offset[0] * slot->bone->m10 + offset[1] * slot->bone->m11 + slot->bone->worldY; + quad->tl.vertices.x = offset[2] * slot->bone->m00 + offset[3] * slot->bone->m01 + slot->bone->worldX; + quad->tl.vertices.y = offset[2] * slot->bone->m10 + offset[3] * slot->bone->m11 + slot->bone->worldY; + quad->tr.vertices.x = offset[4] * slot->bone->m00 + offset[5] * slot->bone->m01 + slot->bone->worldX; + quad->tr.vertices.y = offset[4] * slot->bone->m10 + offset[5] * slot->bone->m11 + slot->bone->worldY; + quad->br.vertices.x = offset[6] * slot->bone->m00 + offset[7] * slot->bone->m01 + slot->bone->worldX; + quad->br.vertices.y = offset[6] * slot->bone->m10 + offset[7] * slot->bone->m11 + slot->bone->worldY; + + // cocos2dx doesn't handle batching for us, so we'll just force a single texture per skeleton. + skeleton->node->atlas = self->atlas; + if (self->atlas->getCapacity() <= skeleton->node->quadCount) { + if (!self->atlas->resizeCapacity(self->atlas->getCapacity() * 2)) return; + } + self->atlas->updateQuad(quad, skeleton->node->quadCount++); +} + +RegionAttachment* RegionAttachment_create (const char* name, AtlasRegion* region) { + Cocos2dxRegionAttachment* self = NEW(Cocos2dxRegionAttachment); + _RegionAttachment_init(SUPER(self), name); + VTABLE(Attachment, self) ->dispose = _Cocos2dxRegionAttachment_dispose; + VTABLE(Attachment, self) ->draw = _Cocos2dxRegionAttachment_draw; + + Cocos2dxAtlasPage* page = SUB_CAST(Cocos2dxAtlasPage, region->page); + self->atlas = page->atlas; + const CCSize& size = page->texture->getContentSizeInPixels(); + float u = region->x / size.width; + float u2 = (region->x + region->width) / size.width; + float v = region->y / size.height; + float v2 = (region->y + region->height) / size.height; + ccV3F_C4B_T2F_Quad* quad = &self->quad; + if (region->rotate) { + quad->tl.texCoords.u = u; + quad->tl.texCoords.v = v2; + quad->tr.texCoords.u = u; + quad->tr.texCoords.v = v; + quad->br.texCoords.u = u2; + quad->br.texCoords.v = v; + quad->bl.texCoords.u = u2; + quad->bl.texCoords.v = v2; + } else { + quad->bl.texCoords.u = u; + quad->bl.texCoords.v = v2; + quad->tl.texCoords.u = u; + quad->tl.texCoords.v = v; + quad->tr.texCoords.u = u2; + quad->tr.texCoords.v = v; + quad->br.texCoords.u = u2; + quad->br.texCoords.v = v2; + } + + quad->bl.vertices.z = 0; + quad->tl.vertices.z = 0; + quad->tr.vertices.z = 0; + quad->br.vertices.z = 0; + + return SUPER(self); +} + +/**/ + +char* _Util_readFile (const char* path, int* length) { + unsigned long size; + char* data = reinterpret_cast(CCFileUtils::sharedFileUtils()->getFileData( + CCFileUtils::sharedFileUtils()->fullPathForFilename(path).c_str(), "r", &size)); + *length = size; + return data; +} + +} diff --git a/spine-cocos2dx/include/spine-cocos2dx/CCSkeleton.h b/spine-cocos2dx/src/spine/spine-cocos2dx.h similarity index 74% rename from spine-cocos2dx/include/spine-cocos2dx/CCSkeleton.h rename to spine-cocos2dx/src/spine/spine-cocos2dx.h index 297302a4f..7852abbd7 100644 --- a/spine-cocos2dx/include/spine-cocos2dx/CCSkeleton.h +++ b/spine-cocos2dx/src/spine/spine-cocos2dx.h @@ -23,26 +23,37 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ -#ifndef SPINE_CCSKELETON_H_ -#define SPINE_CCSKELETON_H_ - +#include #include "cocos2d.h" namespace spine { -class SkeletonData; -class Skeleton; -class AnimationState; -class AnimationStateData; +typedef struct { + AtlasPage super; + cocos2d::CCTexture2D* texture; + cocos2d::CCTextureAtlas* atlas; +} Cocos2dxAtlasPage; + +/**/ + +class CCSkeleton; + +typedef struct { + Skeleton super; + CCSkeleton* node; +} Cocos2dxSkeleton; class CCSkeleton: public cocos2d::CCNodeRGBA, public cocos2d::CCBlendProtocol { public: - Skeleton *skeleton; - AnimationState *state; - bool debug; + Skeleton* skeleton; + AnimationState* state; + bool debugSlots; + bool debugBones; + cocos2d::CCTextureAtlas* atlas; // All region attachments for a skeleton must use the same texture. + unsigned int quadCount; static CCSkeleton* create (SkeletonData* skeletonData); - CCSkeleton (SkeletonData *skeletonData, AnimationStateData *stateData = 0); + CCSkeleton (SkeletonData* skeletonData, AnimationStateData* stateData = 0); virtual ~CCSkeleton (); virtual void update (float deltaTime); @@ -52,5 +63,12 @@ public: CC_PROPERTY(cocos2d::ccBlendFunc, blendFunc, BlendFunc); }; -} /* namespace spine */ -#endif /* SPINE_CCSKELETON_H_ */ +/**/ + +typedef struct { + RegionAttachment super; + cocos2d::ccV3F_C4B_T2F_Quad quad; + cocos2d::CCTextureAtlas* atlas; +} Cocos2dxRegionAttachment; + +}