cocos2d-x support for: 2.2.4, 3.0, 3.1alpha1

This commit is contained in:
NathanSweet 2014-05-16 16:33:30 +02:00
parent 4defc3146a
commit e68c830876
160 changed files with 14572 additions and 1829 deletions

12
.gitignore vendored
View File

@ -12,9 +12,15 @@ target
*.suo *.suo
*.ipch *.ipch
spine-cocos2dx/cocos2dx/ spine-cocos2dx/2/cocos2dx/
!spine-cocos2dx/cocos2dx/Place cocos2dx here.txt !spine-cocos2dx/2/cocos2dx/Place cocos2dx here.txt
spine-cocos2dx/example/proj.win32/Debug spine-cocos2dx/2/example/proj.win32/Debug
spine-cocos2dx/3.0/cocos2dx/
!spine-cocos2dx/3.0/cocos2dx/Place cocos2dx here.txt
spine-cocos2dx/3.0/example/proj.win32/Debug
spine-cocos2dx/3.1/cocos2dx/
!spine-cocos2dx/3.1/cocos2dx/Place cocos2dx here.txt
spine-cocos2dx/3.1/example/proj.win32/Debug
*.swp *.swp
.DS_Store .DS_Store
xcuserdata xcuserdata

View File

@ -1,11 +1,11 @@
# spine-cocos2dx # spine-cocos2dx v2
The spine-cocos2dx runtime provides functionality to load, manipulate and render [Spine](http://esotericsoftware.com) skeletal animation data using [cocos2d-x](http://www.cocos2d-x.org/). spine-cocos2dx is based on [spine-c](https://github.com/EsotericSoftware/spine-runtimes/tree/master/spine-c). The spine-cocos2dx runtime provides functionality to load, manipulate and render [Spine](http://esotericsoftware.com) skeletal animation data using [cocos2d-x](http://www.cocos2d-x.org/). spine-cocos2dx is based on [spine-c](https://github.com/EsotericSoftware/spine-runtimes/tree/master/spine-c).
## Setup ## Setup
1. Download the Spine Runtimes source using [git](https://help.github.com/articles/set-up-git) or by downloading it [as a zip](https://github.com/EsotericSoftware/spine-runtimes/archive/master.zip). 1. Download the Spine Runtimes source using [git](https://help.github.com/articles/set-up-git) or by downloading it [as a zip](https://github.com/EsotericSoftware/spine-runtimes/archive/master.zip).
1. Place the `cocos2dx` directory from a cocos2d-x (cocos2d-2.1rc0-x-2.1.2 or later) distribution into the `spine-cocos2dx` directory. 1. Place the `cocos2dx` directory from a cocos2d-x version 2.2.3 distribution into the `spine-cocos2dx` directory.
1. Open the XCode (Mac) or Visual C++ 2012 Express (Windows) project file from the `spine-cocos2dx/example` directory. Build files are also provided for Android. 1. Open the XCode (Mac) or Visual C++ 2012 Express (Windows) project file from the `spine-cocos2dx/example` directory. Build files are also provided for Android.
Alternatively, the contents of the `spine-c/src`, `spine-c/include` and `spine-cocos2dx/src` directories can be copied into your project. Be sure your header search path will find the contents of the `spine-c/include` and `spine-cocos2dx/src` directories. Note that the includes use `spine/Xxx.h`, so the `spine` directory cannot be omitted when copying the files. Alternatively, the contents of the `spine-c/src`, `spine-c/include` and `spine-cocos2dx/src` directories can be copied into your project. Be sure your header search path will find the contents of the `spine-c/include` and `spine-cocos2dx/src` directories. Note that the includes use `spine/Xxx.h`, so the `spine` directory cannot be omitted when copying the files.

View File

@ -0,0 +1,81 @@
#include "AppDelegate.h"
#include <vector>
#include <string>
#include "SpineboyExample.h"
#include "AppMacros.h"
USING_NS_CC;
using namespace std;
AppDelegate::AppDelegate () {
}
AppDelegate::~AppDelegate () {
}
bool AppDelegate::applicationDidFinishLaunching () {
// initialize director
CCDirector* director = CCDirector::sharedDirector();
CCEGLView* view = CCEGLView::sharedOpenGLView();
director->setOpenGLView(view);
view->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
CCSize frameSize = view->getFrameSize();
vector<string> searchPath;
// In this demo, we select resource according to the frame's height.
// If the resource size is different from design resolution size, you need to set contentScaleFactor.
// We use the ratio of resource's height to the height of design resolution,
// this can make sure that the resource's height could fit for the height of design resolution.
if (frameSize.height > mediumResource.size.height) {
// if the frame's height is larger than the height of medium resource size, select large resource.
searchPath.push_back(largeResource.directory);
director->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
} else if (frameSize.height > smallResource.size.height) {
// if the frame's height is larger than the height of small resource size, select medium resource.
searchPath.push_back(mediumResource.directory);
director->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
} else {
// if the frame's height is smaller than the height of medium resource size, select small resource.
searchPath.push_back(smallResource.directory);
director->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
}
searchPath.push_back("common");
// set searching path
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
auto scene = SpineboyExample::scene();
// run
director->runWithScene(scene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground () {
CCDirector::sharedDirector()->stopAnimation();
// if you use SimpleAudioEngine, it must be paused
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground () {
CCDirector::sharedDirector()->startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -0,0 +1,61 @@
#ifndef _APPMACROS_H_
#define _APPMACROS_H_
#include "cocos2d.h"
/* For demonstrating using one design resolution to match different resources,
or one resource to match different design resolutions.
[Situation 1] Using one design resolution to match different resources.
Please look into Appdelegate::applicationDidFinishLaunching.
We check current device frame size to decide which resource need to be selected.
So if you want to test this situation which said in title '[Situation 1]',
you should change ios simulator to different device(e.g. iphone, iphone-retina3.5, iphone-retina4.0, ipad, ipad-retina),
or change the window size in "proj.XXX/main.cpp" by "CCEGLView::setFrameSize" if you are using win32 or linux plaform
and modify "proj.mac/AppController.mm" by changing the window rectangle.
[Situation 2] Using one resource to match different design resolutions.
The coordinates in your codes is based on your current design resolution rather than resource size.
Therefore, your design resolution could be very large and your resource size could be small.
To test this, just define the marco 'TARGET_DESIGN_RESOLUTION_SIZE' to 'DESIGN_RESOLUTION_2048X1536'
and open iphone simulator or create a window of 480x320 size.
[Note] Normally, developer just need to define one design resolution(e.g. 960x640) with one or more resources.
*/
#define DESIGN_RESOLUTION_480X320 0
#define DESIGN_RESOLUTION_960x640 1
#define DESIGN_RESOLUTION_1024X768 2
#define DESIGN_RESOLUTION_2048X1536 3
/* If you want to switch design resolution, change next line */
#define TARGET_DESIGN_RESOLUTION_SIZE DESIGN_RESOLUTION_960x640
typedef struct tagResource {
cocos2d::CCSize size;
char directory[100];
} Resource;
static Resource smallResource = {cocos2d::CCSize(480, 320), "iphone"};
static Resource mediumResource = {cocos2d::CCSize(960, 640), "iphone-retina"};
static Resource largeResource = {cocos2d::CCSize(1024, 768), "ipad"};
static Resource extralargeResource = {cocos2d::CCSize(2048, 1536), "ipad-retina"};
#if (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_480X320)
static cocos2d::CCSize designResolutionSize = cocos2d::Size(480, 320);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_960x640)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSize(960, 640);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_1024X768)
static cocos2d::CCSize designResolutionSize = cocos2d::Size(1024, 768);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_2048X1536)
static cocos2d::CCSize designResolutionSize = cocos2d::Size(2048, 1536);
#else
#error unknown target design resolution!
#endif
// The font size 24 is designed for small resolution, so we should change it to fit for current design resolution
#define TITLE_FONT_SIZE (cocos2d::Director::getInstance()->getOpenGLView()->getDesignResolutionSize().width / smallResource.size.width * 24)
#endif /* _APPMACROS_H_ */

View File

@ -0,0 +1,71 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 "GoblinsExample.h"
#include "SpineboyExample.h"
#include <iostream>
#include <fstream>
#include <string.h>
USING_NS_CC;
using namespace spine;
using namespace std;
CCScene* GoblinsExample::scene () {
CCScene *scene = CCScene::create();
scene->addChild(GoblinsExample::create());
return scene;
}
bool GoblinsExample::init () {
if (!CCLayerColor::initWithColor(ccc4(128, 128, 128, 255))) return false;
skeletonNode = SkeletonAnimation::createWithFile("goblins-ffd.json", "goblins-ffd.atlas", 1.5f);
skeletonNode->setAnimation(0, "walk", true);
skeletonNode->setSkin("goblin");
CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
skeletonNode->setPosition(ccp(windowSize.width / 2, 20));
addChild(skeletonNode);
scheduleUpdate();
setTouchEnabled(true);
return true;
}
void GoblinsExample::ccTouchesBegan (CCSet* touches, CCEvent* event) {
if (!skeletonNode->debugBones)
skeletonNode->debugBones = true;
else if (skeletonNode->timeScale == 1)
skeletonNode->timeScale = 0.3f;
else
CCDirector::sharedDirector()->replaceScene(SpineboyExample::scene());
}

View File

@ -0,0 +1,49 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 _GOBLINSEXAMPLE_H_
#define _GOBLINSEXAMPLE_H_
#include "cocos2d.h"
#include <spine/spine-cocos2dx.h>
class GoblinsExample : public cocos2d::CCLayerColor {
public:
static cocos2d::CCScene* scene ();
virtual bool init ();
virtual void ccTouchesBegan (cocos2d::CCSet* touches, cocos2d::CCEvent* event);
CREATE_FUNC (GoblinsExample);
private:
spine::SkeletonAnimation* skeletonNode;
};
#endif // _GOBLINSEXAMPLE_H_

View File

@ -0,0 +1,102 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 "SpineboyExample.h"
#include "GoblinsExample.h"
#include <iostream>
#include <fstream>
#include <string.h>
USING_NS_CC;
using namespace spine;
using namespace std;
CCScene* SpineboyExample::scene () {
CCScene *scene = CCScene::create();
scene->addChild(SpineboyExample::create());
return scene;
}
bool SpineboyExample::init () {
if (!CCLayerColor::initWithColor(ccc4(128, 128, 128, 255))) return false;
skeletonNode = SkeletonAnimation::createWithFile("spineboy.json", "spineboy.atlas", 0.6f);
skeletonNode->startListener = [this] (int trackIndex) {
spTrackEntry* entry = spAnimationState_getCurrent(skeletonNode->state, trackIndex);
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
CCLog("%d start: %s", trackIndex, animationName);
};
skeletonNode->endListener = [] (int trackIndex) {
CCLog("%d end", trackIndex);
};
skeletonNode->completeListener = [] (int trackIndex, int loopCount) {
CCLog("%d complete: %d", trackIndex, loopCount);
};
skeletonNode->eventListener = [] (int trackIndex, spEvent* event) {
CCLog("%d event: %s, %d, %f, %s", trackIndex, event->data->name, event->intValue, event->floatValue, event->stringValue);
};
skeletonNode->setMix("walk", "jump", 0.2f);
skeletonNode->setMix("jump", "run", 0.2f);
skeletonNode->setAnimation(0, "walk", true);
spTrackEntry* jumpEntry = skeletonNode->addAnimation(0, "jump", false, 3);
skeletonNode->addAnimation(0, "run", true);
skeletonNode->setStartListener(jumpEntry, [] (int trackIndex) {
CCLog("jumped!", trackIndex);
});
// skeletonNode->addAnimation(1, "test", true);
// skeletonNode->runAction(RepeatForever::create(Sequence::create(FadeOut::create(1), FadeIn::create(1), DelayTime::create(5), NULL)));
CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
skeletonNode->setPosition(ccp(windowSize.width / 2, 20));
addChild(skeletonNode);
scheduleUpdate();
setTouchEnabled(true);
return true;
}
void SpineboyExample::ccTouchesBegan (CCSet* touches, CCEvent* event) {
if (!skeletonNode->debugBones)
skeletonNode->debugBones = true;
else if (skeletonNode->timeScale == 1)
skeletonNode->timeScale = 0.3f;
else
CCDirector::sharedDirector()->replaceScene(GoblinsExample::scene());
}
void SpineboyExample::update (float deltaTime) {
// Test releasing memory.
// CCDirector::sharedDirector()->replaceScene(SpineboyExample::scene());
}

View File

@ -0,0 +1,50 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 _SPINEBOYEXAMPLE_H_
#define _SPINEBOYEXAMPLE_H_
#include "cocos2d.h"
#include <spine/spine-cocos2dx.h>
class SpineboyExample : public cocos2d::CCLayerColor {
public:
static cocos2d::CCScene* scene ();
virtual bool init ();
virtual void ccTouchesBegan (cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void update (float deltaTime);
CREATE_FUNC (SpineboyExample);
private:
spine::SkeletonAnimation* skeletonNode;
};
#endif // _SPINEBOYEXAMPLE_H_

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 239 KiB

After

Width:  |  Height:  |  Size: 239 KiB

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 239 KiB

After

Width:  |  Height:  |  Size: 239 KiB

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 239 KiB

After

Width:  |  Height:  |  Size: 239 KiB

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 239 KiB

After

Width:  |  Height:  |  Size: 239 KiB

View File

@ -0,0 +1,21 @@
#include "main.h"
#include "../Classes/AppDelegate.h"
USING_NS_CC;
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
eglView->setViewName("Spine Example");
eglView->setFrameSize(960, 640);
return CCApplication::sharedApplication()->run();
}

View File

@ -0,0 +1,53 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2012 for Windows Desktop
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spine-cocos2dx", "spine-cocos2dx.vcxproj", "{DB4C84B9-AC6D-46A1-B7E6-A77FE4515ACF}"
ProjectSection(ProjectDependencies) = postProject
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\cocos2dx\cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\cocos2dx\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spine-c", "..\..\..\..\spine-c\spine-c.vcxproj", "{5D74934A-7512-45EE-8402-7B95D3642E85}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DB4C84B9-AC6D-46A1-B7E6-A77FE4515ACF}.Debug|Win32.ActiveCfg = Debug|Win32
{DB4C84B9-AC6D-46A1-B7E6-A77FE4515ACF}.Debug|Win32.Build.0 = Debug|Win32
{DB4C84B9-AC6D-46A1-B7E6-A77FE4515ACF}.Release|Win32.ActiveCfg = Release|Win32
{DB4C84B9-AC6D-46A1-B7E6-A77FE4515ACF}.Release|Win32.Build.0 = Release|Win32
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32
{5D74934A-7512-45EE-8402-7B95D3642E85}.Debug|Win32.ActiveCfg = Debug|Win32
{5D74934A-7512-45EE-8402-7B95D3642E85}.Debug|Win32.Build.0 = Debug|Win32
{5D74934A-7512-45EE-8402-7B95D3642E85}.Release|Win32.ActiveCfg = Release|Win32
{5D74934A-7512-45EE-8402-7B95D3642E85}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{DB4C84B9-AC6D-46A1-B7E6-A77FE4515ACF}</ProjectGuid>
<RootNamespace>spine</RootNamespace>
<Keyword>Win32Proj</Keyword>
<ProjectName>spine-cocos2dx</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration).win32\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration).win32\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration).win32\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration).win32\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LibraryPath>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)..\Classes;$(ProjectDir)..\..\src;$(ProjectDir)..\..\..\..\spine-c\include;$(ProjectDir)..\..\cocos2dx\cocos2dx;$(ProjectDir)..\..\cocos2dx\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\cocos2dx\platform\third_party\win32\OGLES;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>opengl32.lib;glew32.lib;libcocos2d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<EntryPointSymbol>
</EntryPointSymbol>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<IgnoreSpecificDefaultLibraries>libcmt.lib;msvcrt.lib;libcmtd.lib</IgnoreSpecificDefaultLibraries>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;..\Classes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>opengl32.lib;glew32.lib;libcocos2d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\src\spine\PolygonBatch.h" />
<ClInclude Include="..\..\src\spine\SkeletonAnimation.h" />
<ClInclude Include="..\..\src\spine\SkeletonRenderer.h" />
<ClInclude Include="..\..\src\spine\spine-cocos2dx.h" />
<ClInclude Include="..\Classes\AppDelegate.h" />
<ClInclude Include="..\Classes\AppMacros.h" />
<ClInclude Include="..\Classes\GoblinsExample.h" />
<ClInclude Include="..\Classes\SpineboyExample.h" />
<ClInclude Include="main.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\spine\PolygonBatch.cpp" />
<ClCompile Include="..\..\src\spine\SkeletonAnimation.cpp" />
<ClCompile Include="..\..\src\spine\SkeletonRenderer.cpp" />
<ClCompile Include="..\..\src\spine\spine-cocos2dx.cpp" />
<ClCompile Include="..\Classes\AppDelegate.cpp" />
<ClCompile Include="..\Classes\GoblinsExample.cpp" />
<ClCompile Include="..\Classes\SpineboyExample.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\spine-c\spine-c.vcxproj">
<Project>{5d74934a-7512-45ee-8402-7b95d3642e85}</Project>
</ProjectReference>
<ProjectReference Include="..\..\cocos2dx\cocos2dx\proj.win32\cocos2d.vcxproj">
<Project>{98a51ba8-fc3a-415b-ac8f-8c7bd464e93e}</Project>
</ProjectReference>
<ProjectReference Include="..\..\cocos2dx\external\chipmunk\proj.win32\chipmunk.vcxproj">
<Project>{207bc7a9-ccf1-4f2f-a04d-45f72242ae25}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,112 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 <spine/PolygonBatch.h>
#include <spine/extension.h>
USING_NS_CC;
namespace spine {
PolygonBatch* PolygonBatch::createWithCapacity (int capacity) {
PolygonBatch* batch = new PolygonBatch();
batch->initWithCapacity(capacity);
batch->autorelease();
return batch;
}
PolygonBatch::PolygonBatch () :
capacity(0),
vertices(nullptr), verticesCount(0),
triangles(nullptr), trianglesCount(0),
texture(nullptr)
{}
bool PolygonBatch::initWithCapacity (int capacity) {
// 32767 is max index, so 32767 / 3 - (32767 / 3 % 3) = 10920.
CCAssert(capacity <= 10920, "capacity cannot be > 10920");
CCAssert(capacity >= 0, "capacity cannot be < 0");
this->capacity = capacity;
vertices = MALLOC(ccV2F_C4B_T2F, capacity);
triangles = MALLOC(GLushort, capacity * 3);
return true;
}
PolygonBatch::~PolygonBatch () {
FREE(vertices);
FREE(triangles);
}
void PolygonBatch::add (CCTexture2D* addTexture,
const float* addVertices, const float* uvs, int addVerticesCount,
const int* addTriangles, int addTrianglesCount,
ccColor4B* color) {
if (
addTexture != texture
|| verticesCount + (addVerticesCount >> 1) > capacity
|| trianglesCount + addTrianglesCount > capacity * 3) {
this->flush();
texture = addTexture;
}
for (int i = 0; i < addTrianglesCount; ++i, ++trianglesCount)
triangles[trianglesCount] = addTriangles[i] + verticesCount;
for (int i = 0; i < addVerticesCount; i += 2, ++verticesCount) {
ccV2F_C4B_T2F* vertex = vertices + verticesCount;
vertex->vertices.x = addVertices[i];
vertex->vertices.y = addVertices[i + 1];
vertex->colors = *color;
vertex->texCoords.u = uvs[i];
vertex->texCoords.v = uvs[i + 1];
}
}
void PolygonBatch::flush () {
if (!verticesCount) return;
ccGLBindTexture2D(texture->getName());
glEnableVertexAttribArray(kCCVertexAttrib_Position);
glEnableVertexAttribArray(kCCVertexAttrib_Color);
glEnableVertexAttribArray(kCCVertexAttrib_TexCoords);
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), &vertices[0].vertices);
glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ccV2F_C4B_T2F), &vertices[0].colors);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), &vertices[0].texCoords);
glDrawElements(GL_TRIANGLES, trianglesCount, GL_UNSIGNED_SHORT, triangles);
verticesCount = 0;
trianglesCount = 0;
CHECK_GL_ERROR_DEBUG();
}
}

View File

@ -0,0 +1,67 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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_POLYGONBATCH_H_
#define SPINE_POLYGONBATCH_H_
#include "cocos2d.h"
namespace spine {
class PolygonBatch : public cocos2d::CCObject {
public:
static PolygonBatch* createWithCapacity (int capacity);
/** @js ctor */
PolygonBatch();
/** @js NA
* @lua NA */
virtual ~PolygonBatch();
bool initWithCapacity (int capacity);
void add (cocos2d::CCTexture2D* texture,
const float* vertices, const float* uvs, int verticesCount,
const int* triangles, int trianglesCount,
cocos2d::ccColor4B* color);
void flush ();
private:
int capacity;
cocos2d::ccV2F_C4B_T2F* vertices;
int verticesCount;
GLushort* triangles;
int trianglesCount;
cocos2d::CCTexture2D* texture;
};
}
#endif // SPINE_POLYGONBATCH_H_

View File

@ -0,0 +1,220 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 <spine/SkeletonAnimation.h>
#include <spine/spine-cocos2dx.h>
#include <spine/extension.h>
#include <algorithm>
USING_NS_CC;
using std::min;
using std::max;
using std::vector;
namespace spine {
void animationCallback (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) {
((SkeletonAnimation*)state->rendererObject)->onAnimationStateEvent(trackIndex, type, event, loopCount);
}
void trackEntryCallback (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) {
((SkeletonAnimation*)state->rendererObject)->onTrackEntryEvent(trackIndex, type, event, loopCount);
}
void disposeTrackEntry (spAnimationState* self, spTrackEntry* entry) {
if (entry->rendererObject) FREE(entry->rendererObject);
_spTrackEntry_dispose(entry);
}
SkeletonAnimation* SkeletonAnimation::createWithData (spSkeletonData* skeletonData) {
SkeletonAnimation* node = new SkeletonAnimation(skeletonData);
node->autorelease();
return node;
}
SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlas, scale);
node->autorelease();
return node;
}
SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlasFile, scale);
node->autorelease();
return node;
}
void SkeletonAnimation::initialize () {
ownsAnimationStateData = true;
state = spAnimationState_create(spAnimationStateData_create(skeleton->data));
state->rendererObject = this;
state->listener = animationCallback;
_spAnimationState* stateInternal = (_spAnimationState*)state;
stateInternal->disposeTrackEntry = disposeTrackEntry;
}
SkeletonAnimation::SkeletonAnimation (spSkeletonData *skeletonData)
: SkeletonRenderer(skeletonData) {
initialize();
}
SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale)
: SkeletonRenderer(skeletonDataFile, atlas, scale) {
initialize();
}
SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale)
: SkeletonRenderer(skeletonDataFile, atlasFile, scale) {
initialize();
}
SkeletonAnimation::~SkeletonAnimation () {
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
spAnimationState_dispose(state);
}
void SkeletonAnimation::update (float deltaTime) {
super::update(deltaTime);
deltaTime *= timeScale;
spAnimationState_update(state, deltaTime);
spAnimationState_apply(state, skeleton);
spSkeleton_updateWorldTransform(skeleton);
}
void SkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) {
CCAssert(stateData, "stateData cannot be null.");
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
spAnimationState_dispose(state);
ownsAnimationStateData = false;
state = spAnimationState_create(stateData);
state->rendererObject = this;
state->listener = animationCallback;
}
void SkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) {
spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration);
}
spTrackEntry* SkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) {
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
if (!animation) {
CCLog("Spine: Animation not found: %s", name);
return 0;
}
return spAnimationState_setAnimation(state, trackIndex, animation, loop);
}
spTrackEntry* SkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) {
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
if (!animation) {
CCLog("Spine: Animation not found: %s", name);
return 0;
}
return spAnimationState_addAnimation(state, trackIndex, animation, loop, delay);
}
spTrackEntry* SkeletonAnimation::getCurrent (int trackIndex) {
return spAnimationState_getCurrent(state, trackIndex);
}
void SkeletonAnimation::clearTracks () {
spAnimationState_clearTracks(state);
}
void SkeletonAnimation::clearTrack (int trackIndex) {
spAnimationState_clearTrack(state, trackIndex);
}
void SkeletonAnimation::onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) {
switch (type) {
case SP_ANIMATION_START:
if (startListener) startListener(trackIndex);
break;
case SP_ANIMATION_END:
if (endListener) endListener(trackIndex);
break;
case SP_ANIMATION_COMPLETE:
if (completeListener) completeListener(trackIndex, loopCount);
break;
case SP_ANIMATION_EVENT:
if (eventListener) eventListener(trackIndex, event);
break;
}
}
void SkeletonAnimation::onTrackEntryEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) {
spTrackEntry* entry = spAnimationState_getCurrent(state, trackIndex);
if (!entry->rendererObject) return;
_TrackEntryListeners* listeners = (_TrackEntryListeners*)entry->rendererObject;
switch (type) {
case SP_ANIMATION_START:
if (listeners->startListener) listeners->startListener(trackIndex);
break;
case SP_ANIMATION_END:
if (listeners->endListener) listeners->endListener(trackIndex);
break;
case SP_ANIMATION_COMPLETE:
if (listeners->completeListener) listeners->completeListener(trackIndex, loopCount);
break;
case SP_ANIMATION_EVENT:
if (listeners->eventListener) listeners->eventListener(trackIndex, event);
break;
}
}
static _TrackEntryListeners* getListeners (spTrackEntry* entry) {
if (!entry->rendererObject) {
entry->rendererObject = NEW(spine::_TrackEntryListeners);
entry->listener = trackEntryCallback;
}
return (_TrackEntryListeners*)entry->rendererObject;
}
void SkeletonAnimation::setStartListener (spTrackEntry* entry, StartListener listener) {
getListeners(entry)->startListener = listener;
}
void SkeletonAnimation::setEndListener (spTrackEntry* entry, EndListener listener) {
getListeners(entry)->endListener = listener;
}
void SkeletonAnimation::setCompleteListener (spTrackEntry* entry, CompleteListener listener) {
getListeners(entry)->completeListener = listener;
}
void SkeletonAnimation::setEventListener (spTrackEntry* entry, spine::EventListener listener) {
getListeners(entry)->eventListener = listener;
}
}

View File

@ -0,0 +1,351 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 <spine/SkeletonRenderer.h>
#include <spine/spine-cocos2dx.h>
#include <spine/extension.h>
#include <spine/PolygonBatch.h>
#include <algorithm>
USING_NS_CC;
using std::min;
using std::max;
namespace spine {
static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
SkeletonRenderer* SkeletonRenderer::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) {
SkeletonRenderer* node = new SkeletonRenderer(skeletonData, ownsSkeletonData);
node->autorelease();
return node;
}
SkeletonRenderer* SkeletonRenderer::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
SkeletonRenderer* node = new SkeletonRenderer(skeletonDataFile, atlas, scale);
node->autorelease();
return node;
}
SkeletonRenderer* SkeletonRenderer::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
SkeletonRenderer* node = new SkeletonRenderer(skeletonDataFile, atlasFile, scale);
node->autorelease();
return node;
}
void SkeletonRenderer::initialize () {
atlas = 0;
debugSlots = false;
debugBones = false;
timeScale = 1;
worldVertices = MALLOC(float, 1000); // Max number of vertices per mesh.
batch = PolygonBatch::createWithCapacity(2000); // Max number of vertices and triangles per batch.
batch->retain();
blendFunc.src = GL_ONE;
blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
setOpacityModifyRGB(true);
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));
scheduleUpdate();
}
void SkeletonRenderer::setSkeletonData (spSkeletonData *skeletonData, bool ownsSkeletonData) {
skeleton = spSkeleton_create(skeletonData);
rootBone = skeleton->bones[0];
this->ownsSkeletonData = ownsSkeletonData;
}
SkeletonRenderer::SkeletonRenderer () {
initialize();
}
SkeletonRenderer::SkeletonRenderer (spSkeletonData *skeletonData, bool ownsSkeletonData) {
initialize();
setSkeletonData(skeletonData, ownsSkeletonData);
}
SkeletonRenderer::SkeletonRenderer (const char* skeletonDataFile, spAtlas* atlas, float scale) {
initialize();
spSkeletonJson* json = spSkeletonJson_create(atlas);
json->scale = scale == 0 ? (1 / CCDirector::sharedDirector()->getContentScaleFactor()) : scale;
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data.");
spSkeletonJson_dispose(json);
setSkeletonData(skeletonData, true);
}
SkeletonRenderer::SkeletonRenderer (const char* skeletonDataFile, const char* atlasFile, float scale) {
initialize();
atlas = spAtlas_createFromFile(atlasFile, 0);
CCAssert(atlas, "Error reading atlas file.");
spSkeletonJson* json = spSkeletonJson_create(atlas);
json->scale = scale == 0 ? (1 / CCDirector::sharedDirector()->getContentScaleFactor()) : scale;
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
spSkeletonJson_dispose(json);
setSkeletonData(skeletonData, true);
}
SkeletonRenderer::~SkeletonRenderer () {
if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data);
if (atlas) spAtlas_dispose(atlas);
spSkeleton_dispose(skeleton);
batch->release();
}
void SkeletonRenderer::update (float deltaTime) {
spSkeleton_update(skeleton, deltaTime * timeScale);
}
void SkeletonRenderer::draw () {
CC_NODE_DRAW_SETUP();
ccColor3B nodeColor = getColor();
skeleton->r = nodeColor.r / (float)255;
skeleton->g = nodeColor.g / (float)255;
skeleton->b = nodeColor.b / (float)255;
skeleton->a = getOpacity() / (float)255;
int additive = -1;
ccColor4B color;
const float* uvs = nullptr;
int verticesCount = 0;
const int* triangles = nullptr;
int trianglesCount = 0;
float r = 0, g = 0, b = 0, a = 0;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
spSlot* slot = skeleton->drawOrder[i];
if (!slot->attachment) continue;
CCTexture2D *texture = nullptr;
switch (slot->attachment->type) {
case SP_ATTACHMENT_REGION: {
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices);
texture = getTexture(attachment);
uvs = attachment->uvs;
verticesCount = 8;
triangles = quadTriangles;
trianglesCount = 6;
r = attachment->r;
g = attachment->g;
b = attachment->b;
a = attachment->a;
break;
}
case SP_ATTACHMENT_MESH: {
spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment;
spMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices);
texture = getTexture(attachment);
uvs = attachment->uvs;
verticesCount = attachment->verticesCount;
triangles = attachment->triangles;
trianglesCount = attachment->trianglesCount;
r = attachment->r;
g = attachment->g;
b = attachment->b;
a = attachment->a;
break;
}
case SP_ATTACHMENT_SKINNED_MESH: {
spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment;
spSkinnedMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices);
texture = getTexture(attachment);
uvs = attachment->uvs;
verticesCount = attachment->uvsCount;
triangles = attachment->triangles;
trianglesCount = attachment->trianglesCount;
r = attachment->r;
g = attachment->g;
b = attachment->b;
a = attachment->a;
break;
}
}
if (texture) {
if (slot->data->additiveBlending != additive) {
batch->flush();
ccGLBlendFunc(blendFunc.src, slot->data->additiveBlending ? GL_ONE : blendFunc.dst);
additive = slot->data->additiveBlending;
}
color.a = skeleton->a * slot->a * a * 255;
float multiplier = premultipliedAlpha ? color.a : 255;
color.r = skeleton->r * slot->r * r * multiplier;
color.g = skeleton->g * slot->g * g * multiplier;
color.b = skeleton->b * slot->b * b * multiplier;
batch->add(texture, worldVertices, uvs, verticesCount, triangles, trianglesCount, &color);
}
}
batch->flush();
if (debugSlots) {
// Slots.
ccDrawColor4B(0, 0, 255, 255);
glLineWidth(1);
CCPoint points[4];
ccV3F_C4B_T2F_Quad quad;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
spSlot* slot = skeleton->drawOrder[i];
if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue;
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices);
points[0] = ccp(worldVertices[0], worldVertices[1]);
points[1] = ccp(worldVertices[2], worldVertices[3]);
points[2] = ccp(worldVertices[4], worldVertices[5]);
points[3] = ccp(worldVertices[6], worldVertices[7]);
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++) {
spBone *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++) {
spBone *bone = skeleton->bones[i];
ccDrawPoint(ccp(bone->worldX, bone->worldY));
if (i == 0) ccDrawColor4B(0, 255, 0, 255);
}
}
}
CCTexture2D* SkeletonRenderer::getTexture (spRegionAttachment* attachment) const {
return (CCTexture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
}
CCTexture2D* SkeletonRenderer::getTexture (spMeshAttachment* attachment) const {
return (CCTexture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
}
CCTexture2D* SkeletonRenderer::getTexture (spSkinnedMeshAttachment* attachment) const {
return (CCTexture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
}
CCRect SkeletonRenderer::boundingBox () {
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
float scaleX = getScaleX();
float scaleY = getScaleY();
float vertices[8];
for (int i = 0; i < skeleton->slotCount; ++i) {
spSlot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue;
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
minX = min(minX, vertices[SP_VERTEX_X1] * scaleX);
minY = min(minY, vertices[SP_VERTEX_Y1] * scaleY);
maxX = max(maxX, vertices[SP_VERTEX_X1] * scaleX);
maxY = max(maxY, vertices[SP_VERTEX_Y1] * scaleY);
minX = min(minX, vertices[SP_VERTEX_X4] * scaleX);
minY = min(minY, vertices[SP_VERTEX_Y4] * scaleY);
maxX = max(maxX, vertices[SP_VERTEX_X4] * scaleX);
maxY = max(maxY, vertices[SP_VERTEX_Y4] * scaleY);
minX = min(minX, vertices[SP_VERTEX_X2] * scaleX);
minY = min(minY, vertices[SP_VERTEX_Y2] * scaleY);
maxX = max(maxX, vertices[SP_VERTEX_X2] * scaleX);
maxY = max(maxY, vertices[SP_VERTEX_Y2] * scaleY);
minX = min(minX, vertices[SP_VERTEX_X3] * scaleX);
minY = min(minY, vertices[SP_VERTEX_Y3] * scaleY);
maxX = max(maxX, vertices[SP_VERTEX_X3] * scaleX);
maxY = max(maxY, vertices[SP_VERTEX_Y3] * scaleY);
}
CCPoint position = getPosition();
return CCRect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
}
// --- Convenience methods for Skeleton_* functions.
void SkeletonRenderer::updateWorldTransform () {
spSkeleton_updateWorldTransform(skeleton);
}
void SkeletonRenderer::setToSetupPose () {
spSkeleton_setToSetupPose(skeleton);
}
void SkeletonRenderer::setBonesToSetupPose () {
spSkeleton_setBonesToSetupPose(skeleton);
}
void SkeletonRenderer::setSlotsToSetupPose () {
spSkeleton_setSlotsToSetupPose(skeleton);
}
spBone* SkeletonRenderer::findBone (const char* boneName) const {
return spSkeleton_findBone(skeleton, boneName);
}
spSlot* SkeletonRenderer::findSlot (const char* slotName) const {
return spSkeleton_findSlot(skeleton, slotName);
}
bool SkeletonRenderer::setSkin (const char* skinName) {
return spSkeleton_setSkinByName(skeleton, skinName) ? true : false;
}
spAttachment* SkeletonRenderer::getAttachment (const char* slotName, const char* attachmentName) const {
return spSkeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
}
bool SkeletonRenderer::setAttachment (const char* slotName, const char* attachmentName) {
return spSkeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
}
// --- CCBlendProtocol
ccBlendFunc SkeletonRenderer::getBlendFunc () {
return blendFunc;
}
void SkeletonRenderer::setBlendFunc (ccBlendFunc blendFunc) {
this->blendFunc = blendFunc;
}
void SkeletonRenderer::setOpacityModifyRGB (bool value) {
premultipliedAlpha = value;
}
bool SkeletonRenderer::isOpacityModifyRGB () {
return premultipliedAlpha;
}
}

View File

@ -0,0 +1,109 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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_SKELETONRENDERER_H_
#define SPINE_SKELETONRENDERER_H_
#include <spine/spine.h>
#include "cocos2d.h"
namespace spine {
class PolygonBatch;
/** Draws a skeleton. */
class SkeletonRenderer: public cocos2d::CCNodeRGBA, public cocos2d::CCBlendProtocol {
public:
spSkeleton* skeleton;
spBone* rootBone;
float timeScale;
bool debugSlots;
bool debugBones;
bool premultipliedAlpha;
static SkeletonRenderer* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
static SkeletonRenderer* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
static SkeletonRenderer* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
SkeletonRenderer (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
SkeletonRenderer (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
SkeletonRenderer (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
virtual ~SkeletonRenderer ();
virtual void update (float deltaTime);
virtual void draw ();
virtual cocos2d::CCRect boundingBox ();
// --- Convenience methods for common Skeleton_* functions.
void updateWorldTransform ();
void setToSetupPose ();
void setBonesToSetupPose ();
void setSlotsToSetupPose ();
/* Returns 0 if the bone was not found. */
spBone* findBone (const char* boneName) const;
/* Returns 0 if the slot was not found. */
spSlot* findSlot (const char* slotName) const;
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
* attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found.
* @param skin May be 0.*/
bool setSkin (const char* skinName);
/* Returns 0 if the slot or attachment was not found. */
spAttachment* getAttachment (const char* slotName, const char* attachmentName) const;
/* Returns false if the slot or attachment was not found. */
bool setAttachment (const char* slotName, const char* attachmentName);
// --- BlendProtocol
CC_PROPERTY(cocos2d::ccBlendFunc, blendFunc, BlendFunc);
virtual void setOpacityModifyRGB (bool value);
virtual bool isOpacityModifyRGB ();
protected:
SkeletonRenderer ();
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
virtual cocos2d::CCTexture2D* getTexture (spRegionAttachment* attachment) const;
virtual cocos2d::CCTexture2D* getTexture (spMeshAttachment* attachment) const;
virtual cocos2d::CCTexture2D* getTexture (spSkinnedMeshAttachment* attachment) const;
private:
bool ownsSkeletonData;
spAtlas* atlas;
PolygonBatch* batch;
float* worldVertices;
void initialize ();
};
}
#endif /* SPINE_SKELETONRENDERER_H_ */

View File

@ -0,0 +1,54 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 <spine/spine-cocos2dx.h>
#include <spine/extension.h>
USING_NS_CC;
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage(path);
texture->retain();
self->rendererObject = texture;
self->width = texture->getPixelsWide();
self->height = texture->getPixelsHigh();
}
void _spAtlasPage_disposeTexture (spAtlasPage* self) {
((CCTexture2D*)self->rendererObject)->release();
}
char* _spUtil_readFile (const char* path, int* length) {
unsigned long size;
char* data = reinterpret_cast<char*>(CCFileUtils::sharedFileUtils()->getFileData(
CCFileUtils::sharedFileUtils()->fullPathForFilename(path).c_str(), "r", &size));
*length = size;
return data;
}

View File

@ -0,0 +1,15 @@
# spine-cocos2dx v3.0
The spine-cocos2dx runtime provides functionality to load, manipulate and render [Spine](http://esotericsoftware.com) skeletal animation data using [cocos2d-x](http://www.cocos2d-x.org/). spine-cocos2dx is based on [spine-c](https://github.com/EsotericSoftware/spine-runtimes/tree/master/spine-c).
## Setup
1. Download the Spine Runtimes source using [git](https://help.github.com/articles/set-up-git) or by downloading it [as a zip](https://github.com/EsotericSoftware/spine-runtimes/archive/master.zip).
1. Place the contents of a cocos2d-x version 3.0 distribution into the `spine-cocos2dx/cocos2dx` directory.
1. Open the XCode (Mac) or Visual C++ 2012 Express (Windows) project file from the `spine-cocos2dx/example` directory. Build files are also provided for Android.
Alternatively, the contents of the `spine-c/src`, `spine-c/include` and `spine-cocos2dx/src` directories can be copied into your project. Be sure your header search path will find the contents of the `spine-c/include` and `spine-cocos2dx/src` directories. Note that the includes use `spine/Xxx.h`, so the `spine` directory cannot be omitted when copying the files.
## Examples
[Simple example](https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-cocos2dx/example/Classes/ExampleLayer.cpp#L18)

View File

@ -0,0 +1,18 @@
#ifndef _APPDELEGATE_H_
#define _APPDELEGATE_H_
#include "cocos2d.h"
class AppDelegate: private cocos2d::CCApplication {
public:
AppDelegate ();
virtual ~AppDelegate ();
virtual bool applicationDidFinishLaunching ();
virtual void applicationDidEnterBackground ();
virtual void applicationWillEnterForeground ();
};
#endif // _APPDELEGATE_H_

View File

@ -52,7 +52,7 @@ bool GoblinsExample::init () {
skeletonNode->setSkin("goblin"); skeletonNode->setSkin("goblin");
Size windowSize = Director::getInstance()->getWinSize(); Size windowSize = Director::getInstance()->getWinSize();
skeletonNode->setPosition(Vec2(windowSize.width / 2, 20)); skeletonNode->setPosition(ccp(windowSize.width / 2, 20));
addChild(skeletonNode); addChild(skeletonNode);
scheduleUpdate(); scheduleUpdate();

View File

@ -78,7 +78,7 @@ bool SpineboyExample::init () {
// skeletonNode->runAction(RepeatForever::create(Sequence::create(FadeOut::create(1), FadeIn::create(1), DelayTime::create(5), NULL))); // skeletonNode->runAction(RepeatForever::create(Sequence::create(FadeOut::create(1), FadeIn::create(1), DelayTime::create(5), NULL)));
Size windowSize = Director::getInstance()->getWinSize(); Size windowSize = Director::getInstance()->getWinSize();
skeletonNode->setPosition(Vec2(windowSize.width / 2, 20)); skeletonNode->setPosition(Point(windowSize.width / 2, 20));
addChild(skeletonNode); addChild(skeletonNode);
scheduleUpdate(); scheduleUpdate();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1,292 @@
goblins-ffd.png
format: RGBA8888
filter: Linear,Linear
repeat: none
dagger
rotate: false
xy: 2, 28
size: 26, 108
orig: 26, 108
offset: 0, 0
index: -1
goblin/eyes-closed
rotate: false
xy: 137, 29
size: 34, 12
orig: 34, 12
offset: 0, 0
index: -1
goblin/head
rotate: false
xy: 26, 357
size: 103, 66
orig: 103, 66
offset: 0, 0
index: -1
goblin/left-arm
rotate: false
xy: 30, 28
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblin/left-foot
rotate: false
xy: 134, 260
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblin/left-hand
rotate: false
xy: 69, 25
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/left-lower-leg
rotate: false
xy: 134, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblin/left-shoulder
rotate: false
xy: 137, 43
size: 29, 44
orig: 29, 44
offset: 0, 0
index: -1
goblin/left-upper-leg
rotate: false
xy: 30, 65
size: 33, 73
orig: 33, 73
offset: 0, 0
index: -1
goblin/neck
rotate: false
xy: 201, 387
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/pelvis
rotate: false
xy: 26, 140
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblin/right-arm
rotate: false
xy: 171, 84
size: 23, 50
orig: 23, 50
offset: 0, 0
index: -1
goblin/right-foot
rotate: false
xy: 134, 225
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblin/right-hand
rotate: false
xy: 204, 258
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblin/right-lower-leg
rotate: false
xy: 201, 430
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblin/right-shoulder
rotate: false
xy: 130, 89
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblin/right-upper-leg
rotate: false
xy: 98, 214
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblin/torso
rotate: false
xy: 131, 410
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblin/undie-straps
rotate: false
xy: 2, 7
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblin/undies
rotate: false
xy: 199, 227
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
goblingirl/eyes-closed
rotate: false
xy: 59, 2
size: 37, 21
orig: 37, 21
offset: 0, 0
index: -1
goblingirl/head
rotate: false
xy: 26, 425
size: 103, 81
orig: 103, 81
offset: 0, 0
index: -1
goblingirl/left-arm
rotate: false
xy: 201, 190
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblingirl/left-foot
rotate: false
xy: 134, 192
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblingirl/left-hand
rotate: false
xy: 196, 109
size: 35, 40
orig: 35, 40
offset: 0, 0
index: -1
goblingirl/left-lower-leg
rotate: false
xy: 169, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/left-shoulder
rotate: false
xy: 107, 30
size: 28, 46
orig: 28, 46
offset: 0, 0
index: -1
goblingirl/left-upper-leg
rotate: false
xy: 65, 68
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/neck
rotate: false
xy: 204, 297
size: 35, 41
orig: 35, 41
offset: 0, 0
index: -1
goblingirl/pelvis
rotate: false
xy: 131, 365
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblingirl/right-arm
rotate: false
xy: 100, 97
size: 28, 50
orig: 28, 50
offset: 0, 0
index: -1
goblingirl/right-foot
rotate: false
xy: 134, 157
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblingirl/right-hand
rotate: false
xy: 199, 151
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblingirl/right-lower-leg
rotate: false
xy: 96, 279
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblingirl/right-shoulder
rotate: false
xy: 204, 340
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblingirl/right-upper-leg
rotate: false
xy: 98, 149
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblingirl/torso
rotate: false
xy: 26, 259
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblingirl/undie-straps
rotate: false
xy: 134, 136
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblingirl/undies
rotate: false
xy: 196, 78
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
shield
rotate: false
xy: 26, 185
size: 70, 72
orig: 70, 72
offset: 0, 0
index: -1
spear
rotate: false
xy: 2, 138
size: 22, 368
orig: 22, 368
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@ -0,0 +1,194 @@
spineboy.png
format: RGBA8888
filter: Linear,Linear
repeat: none
eye_indifferent
rotate: true
xy: 389, 5
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
eye_surprised
rotate: false
xy: 580, 34
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
front_bracer
rotate: false
xy: 732, 85
size: 35, 48
orig: 35, 48
offset: 0, 0
index: -1
front_fist_closed
rotate: false
xy: 556, 91
size: 45, 49
orig: 45, 49
offset: 0, 0
index: -1
front_fist_open
rotate: false
xy: 668, 32
size: 52, 52
orig: 52, 52
offset: 0, 0
index: -1
front_foot
rotate: false
xy: 924, 201
size: 76, 41
orig: 76, 41
offset: 0, 0
index: -1
front_foot_bend1
rotate: false
xy: 845, 200
size: 77, 42
orig: 77, 42
offset: 0, 0
index: -1
front_foot_bend2
rotate: false
xy: 778, 186
size: 65, 56
orig: 65, 56
offset: 0, 0
index: -1
front_shin
rotate: true
xy: 444, 91
size: 49, 110
orig: 49, 110
offset: 0, 0
index: -1
front_thigh
rotate: true
xy: 603, 89
size: 29, 67
orig: 29, 67
offset: 0, 0
index: -1
front_upper_arm
rotate: true
xy: 672, 86
size: 32, 58
orig: 32, 58
offset: 0, 0
index: -1
goggles
rotate: false
xy: 444, 142
size: 157, 100
orig: 157, 100
offset: 0, 0
index: -1
gun
rotate: false
xy: 603, 120
size: 126, 122
orig: 126, 122
offset: 0, 0
index: -1
head
rotate: false
xy: 279, 63
size: 163, 179
orig: 163, 179
offset: 0, 0
index: -1
mouth_grind
rotate: false
xy: 845, 163
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_oooo
rotate: false
xy: 842, 126
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_smile
rotate: false
xy: 769, 97
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
muzzle
rotate: false
xy: 2, 2
size: 275, 240
orig: 277, 240
offset: 0, 0
index: -1
neck
rotate: false
xy: 903, 173
size: 22, 25
orig: 22, 25
offset: 0, 0
index: -1
rear_bracer
rotate: false
xy: 722, 40
size: 34, 43
orig: 34, 43
offset: 0, 0
index: -1
rear_foot
rotate: false
xy: 444, 11
size: 68, 36
orig: 68, 36
offset: 0, 0
index: -1
rear_foot_bend1
rotate: false
xy: 444, 49
size: 70, 40
orig: 70, 40
offset: 0, 0
index: -1
rear_foot_bend2
rotate: false
xy: 778, 134
size: 62, 50
orig: 62, 50
offset: 0, 0
index: -1
rear_shin
rotate: false
xy: 731, 135
size: 45, 107
orig: 45, 107
offset: 0, 0
index: -1
rear_thigh
rotate: true
xy: 516, 50
size: 39, 62
orig: 39, 62
offset: 0, 0
index: -1
rear_upper_arm
rotate: false
xy: 638, 35
size: 28, 52
orig: 28, 52
offset: 0, 0
index: -1
torso
rotate: true
xy: 279, 2
size: 59, 108
orig: 59, 108
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

View File

@ -0,0 +1,292 @@
goblins-ffd.png
format: RGBA8888
filter: Linear,Linear
repeat: none
dagger
rotate: false
xy: 2, 28
size: 26, 108
orig: 26, 108
offset: 0, 0
index: -1
goblin/eyes-closed
rotate: false
xy: 137, 29
size: 34, 12
orig: 34, 12
offset: 0, 0
index: -1
goblin/head
rotate: false
xy: 26, 357
size: 103, 66
orig: 103, 66
offset: 0, 0
index: -1
goblin/left-arm
rotate: false
xy: 30, 28
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblin/left-foot
rotate: false
xy: 134, 260
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblin/left-hand
rotate: false
xy: 69, 25
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/left-lower-leg
rotate: false
xy: 134, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblin/left-shoulder
rotate: false
xy: 137, 43
size: 29, 44
orig: 29, 44
offset: 0, 0
index: -1
goblin/left-upper-leg
rotate: false
xy: 30, 65
size: 33, 73
orig: 33, 73
offset: 0, 0
index: -1
goblin/neck
rotate: false
xy: 201, 387
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/pelvis
rotate: false
xy: 26, 140
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblin/right-arm
rotate: false
xy: 171, 84
size: 23, 50
orig: 23, 50
offset: 0, 0
index: -1
goblin/right-foot
rotate: false
xy: 134, 225
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblin/right-hand
rotate: false
xy: 204, 258
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblin/right-lower-leg
rotate: false
xy: 201, 430
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblin/right-shoulder
rotate: false
xy: 130, 89
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblin/right-upper-leg
rotate: false
xy: 98, 214
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblin/torso
rotate: false
xy: 131, 410
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblin/undie-straps
rotate: false
xy: 2, 7
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblin/undies
rotate: false
xy: 199, 227
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
goblingirl/eyes-closed
rotate: false
xy: 59, 2
size: 37, 21
orig: 37, 21
offset: 0, 0
index: -1
goblingirl/head
rotate: false
xy: 26, 425
size: 103, 81
orig: 103, 81
offset: 0, 0
index: -1
goblingirl/left-arm
rotate: false
xy: 201, 190
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblingirl/left-foot
rotate: false
xy: 134, 192
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblingirl/left-hand
rotate: false
xy: 196, 109
size: 35, 40
orig: 35, 40
offset: 0, 0
index: -1
goblingirl/left-lower-leg
rotate: false
xy: 169, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/left-shoulder
rotate: false
xy: 107, 30
size: 28, 46
orig: 28, 46
offset: 0, 0
index: -1
goblingirl/left-upper-leg
rotate: false
xy: 65, 68
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/neck
rotate: false
xy: 204, 297
size: 35, 41
orig: 35, 41
offset: 0, 0
index: -1
goblingirl/pelvis
rotate: false
xy: 131, 365
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblingirl/right-arm
rotate: false
xy: 100, 97
size: 28, 50
orig: 28, 50
offset: 0, 0
index: -1
goblingirl/right-foot
rotate: false
xy: 134, 157
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblingirl/right-hand
rotate: false
xy: 199, 151
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblingirl/right-lower-leg
rotate: false
xy: 96, 279
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblingirl/right-shoulder
rotate: false
xy: 204, 340
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblingirl/right-upper-leg
rotate: false
xy: 98, 149
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblingirl/torso
rotate: false
xy: 26, 259
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblingirl/undie-straps
rotate: false
xy: 134, 136
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblingirl/undies
rotate: false
xy: 196, 78
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
shield
rotate: false
xy: 26, 185
size: 70, 72
orig: 70, 72
offset: 0, 0
index: -1
spear
rotate: false
xy: 2, 138
size: 22, 368
orig: 22, 368
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@ -0,0 +1,194 @@
spineboy.png
format: RGBA8888
filter: Linear,Linear
repeat: none
eye_indifferent
rotate: true
xy: 389, 5
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
eye_surprised
rotate: false
xy: 580, 34
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
front_bracer
rotate: false
xy: 732, 85
size: 35, 48
orig: 35, 48
offset: 0, 0
index: -1
front_fist_closed
rotate: false
xy: 556, 91
size: 45, 49
orig: 45, 49
offset: 0, 0
index: -1
front_fist_open
rotate: false
xy: 668, 32
size: 52, 52
orig: 52, 52
offset: 0, 0
index: -1
front_foot
rotate: false
xy: 924, 201
size: 76, 41
orig: 76, 41
offset: 0, 0
index: -1
front_foot_bend1
rotate: false
xy: 845, 200
size: 77, 42
orig: 77, 42
offset: 0, 0
index: -1
front_foot_bend2
rotate: false
xy: 778, 186
size: 65, 56
orig: 65, 56
offset: 0, 0
index: -1
front_shin
rotate: true
xy: 444, 91
size: 49, 110
orig: 49, 110
offset: 0, 0
index: -1
front_thigh
rotate: true
xy: 603, 89
size: 29, 67
orig: 29, 67
offset: 0, 0
index: -1
front_upper_arm
rotate: true
xy: 672, 86
size: 32, 58
orig: 32, 58
offset: 0, 0
index: -1
goggles
rotate: false
xy: 444, 142
size: 157, 100
orig: 157, 100
offset: 0, 0
index: -1
gun
rotate: false
xy: 603, 120
size: 126, 122
orig: 126, 122
offset: 0, 0
index: -1
head
rotate: false
xy: 279, 63
size: 163, 179
orig: 163, 179
offset: 0, 0
index: -1
mouth_grind
rotate: false
xy: 845, 163
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_oooo
rotate: false
xy: 842, 126
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_smile
rotate: false
xy: 769, 97
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
muzzle
rotate: false
xy: 2, 2
size: 275, 240
orig: 277, 240
offset: 0, 0
index: -1
neck
rotate: false
xy: 903, 173
size: 22, 25
orig: 22, 25
offset: 0, 0
index: -1
rear_bracer
rotate: false
xy: 722, 40
size: 34, 43
orig: 34, 43
offset: 0, 0
index: -1
rear_foot
rotate: false
xy: 444, 11
size: 68, 36
orig: 68, 36
offset: 0, 0
index: -1
rear_foot_bend1
rotate: false
xy: 444, 49
size: 70, 40
orig: 70, 40
offset: 0, 0
index: -1
rear_foot_bend2
rotate: false
xy: 778, 134
size: 62, 50
orig: 62, 50
offset: 0, 0
index: -1
rear_shin
rotate: false
xy: 731, 135
size: 45, 107
orig: 45, 107
offset: 0, 0
index: -1
rear_thigh
rotate: true
xy: 516, 50
size: 39, 62
orig: 39, 62
offset: 0, 0
index: -1
rear_upper_arm
rotate: false
xy: 638, 35
size: 28, 52
orig: 28, 52
offset: 0, 0
index: -1
torso
rotate: true
xy: 279, 2
size: 59, 108
orig: 59, 108
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

View File

@ -0,0 +1,292 @@
goblins-ffd.png
format: RGBA8888
filter: Linear,Linear
repeat: none
dagger
rotate: false
xy: 2, 28
size: 26, 108
orig: 26, 108
offset: 0, 0
index: -1
goblin/eyes-closed
rotate: false
xy: 137, 29
size: 34, 12
orig: 34, 12
offset: 0, 0
index: -1
goblin/head
rotate: false
xy: 26, 357
size: 103, 66
orig: 103, 66
offset: 0, 0
index: -1
goblin/left-arm
rotate: false
xy: 30, 28
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblin/left-foot
rotate: false
xy: 134, 260
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblin/left-hand
rotate: false
xy: 69, 25
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/left-lower-leg
rotate: false
xy: 134, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblin/left-shoulder
rotate: false
xy: 137, 43
size: 29, 44
orig: 29, 44
offset: 0, 0
index: -1
goblin/left-upper-leg
rotate: false
xy: 30, 65
size: 33, 73
orig: 33, 73
offset: 0, 0
index: -1
goblin/neck
rotate: false
xy: 201, 387
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/pelvis
rotate: false
xy: 26, 140
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblin/right-arm
rotate: false
xy: 171, 84
size: 23, 50
orig: 23, 50
offset: 0, 0
index: -1
goblin/right-foot
rotate: false
xy: 134, 225
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblin/right-hand
rotate: false
xy: 204, 258
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblin/right-lower-leg
rotate: false
xy: 201, 430
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblin/right-shoulder
rotate: false
xy: 130, 89
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblin/right-upper-leg
rotate: false
xy: 98, 214
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblin/torso
rotate: false
xy: 131, 410
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblin/undie-straps
rotate: false
xy: 2, 7
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblin/undies
rotate: false
xy: 199, 227
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
goblingirl/eyes-closed
rotate: false
xy: 59, 2
size: 37, 21
orig: 37, 21
offset: 0, 0
index: -1
goblingirl/head
rotate: false
xy: 26, 425
size: 103, 81
orig: 103, 81
offset: 0, 0
index: -1
goblingirl/left-arm
rotate: false
xy: 201, 190
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblingirl/left-foot
rotate: false
xy: 134, 192
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblingirl/left-hand
rotate: false
xy: 196, 109
size: 35, 40
orig: 35, 40
offset: 0, 0
index: -1
goblingirl/left-lower-leg
rotate: false
xy: 169, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/left-shoulder
rotate: false
xy: 107, 30
size: 28, 46
orig: 28, 46
offset: 0, 0
index: -1
goblingirl/left-upper-leg
rotate: false
xy: 65, 68
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/neck
rotate: false
xy: 204, 297
size: 35, 41
orig: 35, 41
offset: 0, 0
index: -1
goblingirl/pelvis
rotate: false
xy: 131, 365
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblingirl/right-arm
rotate: false
xy: 100, 97
size: 28, 50
orig: 28, 50
offset: 0, 0
index: -1
goblingirl/right-foot
rotate: false
xy: 134, 157
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblingirl/right-hand
rotate: false
xy: 199, 151
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblingirl/right-lower-leg
rotate: false
xy: 96, 279
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblingirl/right-shoulder
rotate: false
xy: 204, 340
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblingirl/right-upper-leg
rotate: false
xy: 98, 149
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblingirl/torso
rotate: false
xy: 26, 259
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblingirl/undie-straps
rotate: false
xy: 134, 136
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblingirl/undies
rotate: false
xy: 196, 78
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
shield
rotate: false
xy: 26, 185
size: 70, 72
orig: 70, 72
offset: 0, 0
index: -1
spear
rotate: false
xy: 2, 138
size: 22, 368
orig: 22, 368
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@ -0,0 +1,194 @@
spineboy.png
format: RGBA8888
filter: Linear,Linear
repeat: none
eye_indifferent
rotate: true
xy: 389, 5
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
eye_surprised
rotate: false
xy: 580, 34
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
front_bracer
rotate: false
xy: 732, 85
size: 35, 48
orig: 35, 48
offset: 0, 0
index: -1
front_fist_closed
rotate: false
xy: 556, 91
size: 45, 49
orig: 45, 49
offset: 0, 0
index: -1
front_fist_open
rotate: false
xy: 668, 32
size: 52, 52
orig: 52, 52
offset: 0, 0
index: -1
front_foot
rotate: false
xy: 924, 201
size: 76, 41
orig: 76, 41
offset: 0, 0
index: -1
front_foot_bend1
rotate: false
xy: 845, 200
size: 77, 42
orig: 77, 42
offset: 0, 0
index: -1
front_foot_bend2
rotate: false
xy: 778, 186
size: 65, 56
orig: 65, 56
offset: 0, 0
index: -1
front_shin
rotate: true
xy: 444, 91
size: 49, 110
orig: 49, 110
offset: 0, 0
index: -1
front_thigh
rotate: true
xy: 603, 89
size: 29, 67
orig: 29, 67
offset: 0, 0
index: -1
front_upper_arm
rotate: true
xy: 672, 86
size: 32, 58
orig: 32, 58
offset: 0, 0
index: -1
goggles
rotate: false
xy: 444, 142
size: 157, 100
orig: 157, 100
offset: 0, 0
index: -1
gun
rotate: false
xy: 603, 120
size: 126, 122
orig: 126, 122
offset: 0, 0
index: -1
head
rotate: false
xy: 279, 63
size: 163, 179
orig: 163, 179
offset: 0, 0
index: -1
mouth_grind
rotate: false
xy: 845, 163
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_oooo
rotate: false
xy: 842, 126
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_smile
rotate: false
xy: 769, 97
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
muzzle
rotate: false
xy: 2, 2
size: 275, 240
orig: 277, 240
offset: 0, 0
index: -1
neck
rotate: false
xy: 903, 173
size: 22, 25
orig: 22, 25
offset: 0, 0
index: -1
rear_bracer
rotate: false
xy: 722, 40
size: 34, 43
orig: 34, 43
offset: 0, 0
index: -1
rear_foot
rotate: false
xy: 444, 11
size: 68, 36
orig: 68, 36
offset: 0, 0
index: -1
rear_foot_bend1
rotate: false
xy: 444, 49
size: 70, 40
orig: 70, 40
offset: 0, 0
index: -1
rear_foot_bend2
rotate: false
xy: 778, 134
size: 62, 50
orig: 62, 50
offset: 0, 0
index: -1
rear_shin
rotate: false
xy: 731, 135
size: 45, 107
orig: 45, 107
offset: 0, 0
index: -1
rear_thigh
rotate: true
xy: 516, 50
size: 39, 62
orig: 39, 62
offset: 0, 0
index: -1
rear_upper_arm
rotate: false
xy: 638, 35
size: 28, 52
orig: 28, 52
offset: 0, 0
index: -1
torso
rotate: true
xy: 279, 2
size: 59, 108
orig: 59, 108
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

View File

@ -0,0 +1,292 @@
goblins-ffd.png
format: RGBA8888
filter: Linear,Linear
repeat: none
dagger
rotate: false
xy: 2, 28
size: 26, 108
orig: 26, 108
offset: 0, 0
index: -1
goblin/eyes-closed
rotate: false
xy: 137, 29
size: 34, 12
orig: 34, 12
offset: 0, 0
index: -1
goblin/head
rotate: false
xy: 26, 357
size: 103, 66
orig: 103, 66
offset: 0, 0
index: -1
goblin/left-arm
rotate: false
xy: 30, 28
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblin/left-foot
rotate: false
xy: 134, 260
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblin/left-hand
rotate: false
xy: 69, 25
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/left-lower-leg
rotate: false
xy: 134, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblin/left-shoulder
rotate: false
xy: 137, 43
size: 29, 44
orig: 29, 44
offset: 0, 0
index: -1
goblin/left-upper-leg
rotate: false
xy: 30, 65
size: 33, 73
orig: 33, 73
offset: 0, 0
index: -1
goblin/neck
rotate: false
xy: 201, 387
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/pelvis
rotate: false
xy: 26, 140
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblin/right-arm
rotate: false
xy: 171, 84
size: 23, 50
orig: 23, 50
offset: 0, 0
index: -1
goblin/right-foot
rotate: false
xy: 134, 225
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblin/right-hand
rotate: false
xy: 204, 258
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblin/right-lower-leg
rotate: false
xy: 201, 430
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblin/right-shoulder
rotate: false
xy: 130, 89
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblin/right-upper-leg
rotate: false
xy: 98, 214
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblin/torso
rotate: false
xy: 131, 410
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblin/undie-straps
rotate: false
xy: 2, 7
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblin/undies
rotate: false
xy: 199, 227
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
goblingirl/eyes-closed
rotate: false
xy: 59, 2
size: 37, 21
orig: 37, 21
offset: 0, 0
index: -1
goblingirl/head
rotate: false
xy: 26, 425
size: 103, 81
orig: 103, 81
offset: 0, 0
index: -1
goblingirl/left-arm
rotate: false
xy: 201, 190
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblingirl/left-foot
rotate: false
xy: 134, 192
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblingirl/left-hand
rotate: false
xy: 196, 109
size: 35, 40
orig: 35, 40
offset: 0, 0
index: -1
goblingirl/left-lower-leg
rotate: false
xy: 169, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/left-shoulder
rotate: false
xy: 107, 30
size: 28, 46
orig: 28, 46
offset: 0, 0
index: -1
goblingirl/left-upper-leg
rotate: false
xy: 65, 68
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/neck
rotate: false
xy: 204, 297
size: 35, 41
orig: 35, 41
offset: 0, 0
index: -1
goblingirl/pelvis
rotate: false
xy: 131, 365
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblingirl/right-arm
rotate: false
xy: 100, 97
size: 28, 50
orig: 28, 50
offset: 0, 0
index: -1
goblingirl/right-foot
rotate: false
xy: 134, 157
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblingirl/right-hand
rotate: false
xy: 199, 151
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblingirl/right-lower-leg
rotate: false
xy: 96, 279
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblingirl/right-shoulder
rotate: false
xy: 204, 340
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblingirl/right-upper-leg
rotate: false
xy: 98, 149
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblingirl/torso
rotate: false
xy: 26, 259
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblingirl/undie-straps
rotate: false
xy: 134, 136
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblingirl/undies
rotate: false
xy: 196, 78
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
shield
rotate: false
xy: 26, 185
size: 70, 72
orig: 70, 72
offset: 0, 0
index: -1
spear
rotate: false
xy: 2, 138
size: 22, 368
orig: 22, 368
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@ -0,0 +1,194 @@
spineboy.png
format: RGBA8888
filter: Linear,Linear
repeat: none
eye_indifferent
rotate: true
xy: 389, 5
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
eye_surprised
rotate: false
xy: 580, 34
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
front_bracer
rotate: false
xy: 732, 85
size: 35, 48
orig: 35, 48
offset: 0, 0
index: -1
front_fist_closed
rotate: false
xy: 556, 91
size: 45, 49
orig: 45, 49
offset: 0, 0
index: -1
front_fist_open
rotate: false
xy: 668, 32
size: 52, 52
orig: 52, 52
offset: 0, 0
index: -1
front_foot
rotate: false
xy: 924, 201
size: 76, 41
orig: 76, 41
offset: 0, 0
index: -1
front_foot_bend1
rotate: false
xy: 845, 200
size: 77, 42
orig: 77, 42
offset: 0, 0
index: -1
front_foot_bend2
rotate: false
xy: 778, 186
size: 65, 56
orig: 65, 56
offset: 0, 0
index: -1
front_shin
rotate: true
xy: 444, 91
size: 49, 110
orig: 49, 110
offset: 0, 0
index: -1
front_thigh
rotate: true
xy: 603, 89
size: 29, 67
orig: 29, 67
offset: 0, 0
index: -1
front_upper_arm
rotate: true
xy: 672, 86
size: 32, 58
orig: 32, 58
offset: 0, 0
index: -1
goggles
rotate: false
xy: 444, 142
size: 157, 100
orig: 157, 100
offset: 0, 0
index: -1
gun
rotate: false
xy: 603, 120
size: 126, 122
orig: 126, 122
offset: 0, 0
index: -1
head
rotate: false
xy: 279, 63
size: 163, 179
orig: 163, 179
offset: 0, 0
index: -1
mouth_grind
rotate: false
xy: 845, 163
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_oooo
rotate: false
xy: 842, 126
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_smile
rotate: false
xy: 769, 97
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
muzzle
rotate: false
xy: 2, 2
size: 275, 240
orig: 277, 240
offset: 0, 0
index: -1
neck
rotate: false
xy: 903, 173
size: 22, 25
orig: 22, 25
offset: 0, 0
index: -1
rear_bracer
rotate: false
xy: 722, 40
size: 34, 43
orig: 34, 43
offset: 0, 0
index: -1
rear_foot
rotate: false
xy: 444, 11
size: 68, 36
orig: 68, 36
offset: 0, 0
index: -1
rear_foot_bend1
rotate: false
xy: 444, 49
size: 70, 40
orig: 70, 40
offset: 0, 0
index: -1
rear_foot_bend2
rotate: false
xy: 778, 134
size: 62, 50
orig: 62, 50
offset: 0, 0
index: -1
rear_shin
rotate: false
xy: 731, 135
size: 45, 107
orig: 45, 107
offset: 0, 0
index: -1
rear_thigh
rotate: true
xy: 516, 50
size: 39, 62
orig: 39, 62
offset: 0, 0
index: -1
rear_upper_arm
rotate: false
xy: 638, 35
size: 28, 52
orig: 28, 52
offset: 0, 0
index: -1
torso
rotate: true
xy: 279, 2
size: 59, 108
orig: 59, 108
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

View File

@ -0,0 +1,9 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#endif // __MAIN_H__

View File

@ -10,7 +10,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\cocos2d
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\cocos2dx\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\cocos2dx\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spine-c", "..\..\..\spine-c\spine-c.vcxproj", "{5D74934A-7512-45EE-8402-7B95D3642E85}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spine-c", "..\..\..\..\spine-c\spine-c.vcxproj", "{5D74934A-7512-45EE-8402-7B95D3642E85}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -70,7 +70,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)..\Classes;$(ProjectDir)..\..\src;$(ProjectDir)..\..\..\spine-c\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\Classes;$(ProjectDir)..\..\src;$(ProjectDir)..\..\..\..\spine-c\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild> <MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@ -150,7 +150,7 @@
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\spine-c\spine-c.vcxproj"> <ProjectReference Include="..\..\..\..\spine-c\spine-c.vcxproj">
<Project>{5d74934a-7512-45ee-8402-7b95d3642e85}</Project> <Project>{5d74934a-7512-45ee-8402-7b95d3642e85}</Project>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\cocos2dx\cocos\2d\cocos2d.vcxproj"> <ProjectReference Include="..\..\cocos2dx\cocos\2d\cocos2d.vcxproj">

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="win32">
<UniqueIdentifier>{ef769de4-53ac-449d-92e6-e67ec8d7414e}</UniqueIdentifier>
</Filter>
<Filter Include="Classes">
<UniqueIdentifier>{0dcd52ca-d521-4ba1-a1fa-c0d58a2df402}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{54b66b2b-0990-4335-a821-332c44b6f83e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h">
<Filter>win32</Filter>
</ClInclude>
<ClInclude Include="..\Classes\AppDelegate.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="..\Classes\AppMacros.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="..\..\src\spine\SkeletonRenderer.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\..\src\spine\spine-cocos2dx.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\..\src\spine\SkeletonAnimation.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\..\src\spine\PolygonBatch.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\Classes\SpineboyExample.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="..\Classes\GoblinsExample.h">
<Filter>Classes</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>win32</Filter>
</ClCompile>
<ClCompile Include="..\Classes\AppDelegate.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="..\..\src\spine\SkeletonRenderer.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\..\src\spine\spine-cocos2dx.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\..\src\spine\SkeletonAnimation.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\..\src\spine\PolygonBatch.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\Classes\SpineboyExample.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="..\Classes\GoblinsExample.cpp">
<Filter>Classes</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -67,7 +67,7 @@ PolygonBatch::~PolygonBatch () {
void PolygonBatch::add (const Texture2D* addTexture, void PolygonBatch::add (const Texture2D* addTexture,
const float* addVertices, const float* uvs, int addVerticesCount, const float* addVertices, const float* uvs, int addVerticesCount,
const int* addTriangles, int addTrianglesCount, const int* addTriangles, int addTrianglesCount,
cocos2d::Color4B* color) { Color4B* color) {
if ( if (
addTexture != texture addTexture != texture

View File

@ -0,0 +1,103 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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_SKELETONANIMATION_H_
#define SPINE_SKELETONANIMATION_H_
#include <spine/spine.h>
#include <spine/SkeletonRenderer.h>
#include "cocos2d.h"
namespace spine {
typedef std::function<void(int trackIndex)> StartListener;
typedef std::function<void(int trackIndex)> EndListener;
typedef std::function<void(int trackIndex, int loopCount)> CompleteListener;
typedef std::function<void(int trackIndex, spEvent* event)> EventListener;
typedef struct _TrackEntryListeners {
StartListener startListener;
EndListener endListener;
CompleteListener completeListener;
EventListener eventListener;
} _TrackEntryListeners;
/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be
* played later. */
class SkeletonAnimation: public SkeletonRenderer {
public:
spAnimationState* state;
static SkeletonAnimation* createWithData (spSkeletonData* skeletonData);
static SkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
static SkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
SkeletonAnimation (spSkeletonData* skeletonData);
SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
virtual ~SkeletonAnimation ();
virtual void update (float deltaTime);
void setAnimationStateData (spAnimationStateData* stateData);
void setMix (const char* fromAnimation, const char* toAnimation, float duration);
spTrackEntry* setAnimation (int trackIndex, const char* name, bool loop);
spTrackEntry* addAnimation (int trackIndex, const char* name, bool loop, float delay = 0);
spTrackEntry* getCurrent (int trackIndex = 0);
void clearTracks ();
void clearTrack (int trackIndex = 0);
StartListener startListener;
EndListener endListener;
CompleteListener completeListener;
EventListener eventListener;
void setStartListener (spTrackEntry* entry, StartListener listener);
void setEndListener (spTrackEntry* entry, EndListener listener);
void setCompleteListener (spTrackEntry* entry, CompleteListener listener);
void setEventListener (spTrackEntry* entry, EventListener listener);
virtual void onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount);
virtual void onTrackEntryEvent (int trackIndex, spEventType type, spEvent* event, int loopCount);
protected:
SkeletonAnimation ();
private:
typedef SkeletonRenderer super;
bool ownsAnimationStateData;
void initialize ();
};
}
#endif /* SPINE_SKELETONANIMATION_H_ */

View File

@ -0,0 +1,362 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 <spine/SkeletonRenderer.h>
#include <spine/spine-cocos2dx.h>
#include <spine/extension.h>
#include <spine/PolygonBatch.h>
#include <algorithm>
USING_NS_CC;
using std::min;
using std::max;
namespace spine {
static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
SkeletonRenderer* SkeletonRenderer::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) {
SkeletonRenderer* node = new SkeletonRenderer(skeletonData, ownsSkeletonData);
node->autorelease();
return node;
}
SkeletonRenderer* SkeletonRenderer::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
SkeletonRenderer* node = new SkeletonRenderer(skeletonDataFile, atlas, scale);
node->autorelease();
return node;
}
SkeletonRenderer* SkeletonRenderer::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
SkeletonRenderer* node = new SkeletonRenderer(skeletonDataFile, atlasFile, scale);
node->autorelease();
return node;
}
void SkeletonRenderer::initialize () {
atlas = 0;
debugSlots = false;
debugBones = false;
timeScale = 1;
worldVertices = MALLOC(float, 1000); // Max number of vertices per mesh.
batch = PolygonBatch::createWithCapacity(2000); // Max number of vertices and triangles per batch.
batch->retain();
blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setOpacityModifyRGB(true);
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
scheduleUpdate();
}
void SkeletonRenderer::setSkeletonData (spSkeletonData *skeletonData, bool ownsSkeletonData) {
skeleton = spSkeleton_create(skeletonData);
rootBone = skeleton->bones[0];
this->ownsSkeletonData = ownsSkeletonData;
}
SkeletonRenderer::SkeletonRenderer () {
initialize();
}
SkeletonRenderer::SkeletonRenderer (spSkeletonData *skeletonData, bool ownsSkeletonData) {
initialize();
setSkeletonData(skeletonData, ownsSkeletonData);
}
SkeletonRenderer::SkeletonRenderer (const char* skeletonDataFile, spAtlas* atlas, float scale) {
initialize();
spSkeletonJson* json = spSkeletonJson_create(atlas);
json->scale = scale == 0 ? (1 / Director::getInstance()->getContentScaleFactor()) : scale;
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data.");
spSkeletonJson_dispose(json);
setSkeletonData(skeletonData, true);
}
SkeletonRenderer::SkeletonRenderer (const char* skeletonDataFile, const char* atlasFile, float scale) {
initialize();
atlas = spAtlas_createFromFile(atlasFile, 0);
CCASSERT(atlas, "Error reading atlas file.");
spSkeletonJson* json = spSkeletonJson_create(atlas);
json->scale = scale == 0 ? (1 / Director::getInstance()->getContentScaleFactor()) : scale;
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
spSkeletonJson_dispose(json);
setSkeletonData(skeletonData, true);
}
SkeletonRenderer::~SkeletonRenderer () {
if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data);
if (atlas) spAtlas_dispose(atlas);
spSkeleton_dispose(skeleton);
batch->release();
}
void SkeletonRenderer::update (float deltaTime) {
spSkeleton_update(skeleton, deltaTime * timeScale);
}
void SkeletonRenderer::draw(Renderer* renderer, const kmMat4& transform, bool transformUpdated) {
drawCommand.init(_globalZOrder);
drawCommand.func = CC_CALLBACK_0(SkeletonRenderer::drawSkeleton, this, transform, transformUpdated);
renderer->addCommand(&drawCommand);
}
void SkeletonRenderer::drawSkeleton (const kmMat4& transform, bool transformUpdated) {
getShaderProgram()->use();
getShaderProgram()->setUniformsForBuiltins(transform);
Color3B nodeColor = getColor();
skeleton->r = nodeColor.r / (float)255;
skeleton->g = nodeColor.g / (float)255;
skeleton->b = nodeColor.b / (float)255;
skeleton->a = getOpacity() / (float)255;
int additive = -1;
Color4B color;
const float* uvs = nullptr;
int verticesCount = 0;
const int* triangles = nullptr;
int trianglesCount = 0;
float r = 0, g = 0, b = 0, a = 0;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
spSlot* slot = skeleton->drawOrder[i];
if (!slot->attachment) continue;
Texture2D *texture = nullptr;
switch (slot->attachment->type) {
case SP_ATTACHMENT_REGION: {
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices);
texture = getTexture(attachment);
uvs = attachment->uvs;
verticesCount = 8;
triangles = quadTriangles;
trianglesCount = 6;
r = attachment->r;
g = attachment->g;
b = attachment->b;
a = attachment->a;
break;
}
case SP_ATTACHMENT_MESH: {
spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment;
spMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices);
texture = getTexture(attachment);
uvs = attachment->uvs;
verticesCount = attachment->verticesCount;
triangles = attachment->triangles;
trianglesCount = attachment->trianglesCount;
r = attachment->r;
g = attachment->g;
b = attachment->b;
a = attachment->a;
break;
}
case SP_ATTACHMENT_SKINNED_MESH: {
spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment;
spSkinnedMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices);
texture = getTexture(attachment);
uvs = attachment->uvs;
verticesCount = attachment->uvsCount;
triangles = attachment->triangles;
trianglesCount = attachment->trianglesCount;
r = attachment->r;
g = attachment->g;
b = attachment->b;
a = attachment->a;
break;
}
}
if (texture) {
if (slot->data->additiveBlending != additive) {
batch->flush();
GL::blendFunc(blendFunc.src, slot->data->additiveBlending ? GL_ONE : blendFunc.dst);
additive = slot->data->additiveBlending;
}
color.a = skeleton->a * slot->a * a * 255;
float multiplier = premultipliedAlpha ? color.a : 255;
color.r = skeleton->r * slot->r * r * multiplier;
color.g = skeleton->g * slot->g * g * multiplier;
color.b = skeleton->b * slot->b * b * multiplier;
batch->add(texture, worldVertices, uvs, verticesCount, triangles, trianglesCount, &color);
}
}
batch->flush();
if (debugSlots || debugBones) {
kmGLPushMatrix();
kmGLLoadMatrix(&transform);
if (debugSlots) {
// Slots.
ccDrawColor4B(0, 0, 255, 255);
glLineWidth(1);
CCPoint points[4];
ccV3F_C4B_T2F_Quad quad;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
spSlot* slot = skeleton->drawOrder[i];
if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue;
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices);
points[0] = Point(worldVertices[0], worldVertices[1]);
points[1] = Point(worldVertices[2], worldVertices[3]);
points[2] = Point(worldVertices[4], worldVertices[5]);
points[3] = Point(worldVertices[6], worldVertices[7]);
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++) {
spBone *bone = skeleton->bones[i];
float x = bone->data->length * bone->m00 + bone->worldX;
float y = bone->data->length * bone->m10 + bone->worldY;
ccDrawLine(Point(bone->worldX, bone->worldY), Point(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++) {
spBone *bone = skeleton->bones[i];
ccDrawPoint(Point(bone->worldX, bone->worldY));
if (i == 0) ccDrawColor4B(0, 255, 0, 255);
}
}
kmGLPopMatrix();
}
}
Texture2D* SkeletonRenderer::getTexture (spRegionAttachment* attachment) const {
return (Texture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
}
Texture2D* SkeletonRenderer::getTexture (spMeshAttachment* attachment) const {
return (Texture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
}
Texture2D* SkeletonRenderer::getTexture (spSkinnedMeshAttachment* attachment) const {
return (Texture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
}
Rect SkeletonRenderer::boundingBox () {
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
float scaleX = getScaleX();
float scaleY = getScaleY();
float vertices[8];
for (int i = 0; i < skeleton->slotCount; ++i) {
spSlot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue;
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
minX = min(minX, vertices[SP_VERTEX_X1] * scaleX);
minY = min(minY, vertices[SP_VERTEX_Y1] * scaleY);
maxX = max(maxX, vertices[SP_VERTEX_X1] * scaleX);
maxY = max(maxY, vertices[SP_VERTEX_Y1] * scaleY);
minX = min(minX, vertices[SP_VERTEX_X4] * scaleX);
minY = min(minY, vertices[SP_VERTEX_Y4] * scaleY);
maxX = max(maxX, vertices[SP_VERTEX_X4] * scaleX);
maxY = max(maxY, vertices[SP_VERTEX_Y4] * scaleY);
minX = min(minX, vertices[SP_VERTEX_X2] * scaleX);
minY = min(minY, vertices[SP_VERTEX_Y2] * scaleY);
maxX = max(maxX, vertices[SP_VERTEX_X2] * scaleX);
maxY = max(maxY, vertices[SP_VERTEX_Y2] * scaleY);
minX = min(minX, vertices[SP_VERTEX_X3] * scaleX);
minY = min(minY, vertices[SP_VERTEX_Y3] * scaleY);
maxX = max(maxX, vertices[SP_VERTEX_X3] * scaleX);
maxY = max(maxY, vertices[SP_VERTEX_Y3] * scaleY);
}
Point position = getPosition();
return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
}
// --- Convenience methods for Skeleton_* functions.
void SkeletonRenderer::updateWorldTransform () {
spSkeleton_updateWorldTransform(skeleton);
}
void SkeletonRenderer::setToSetupPose () {
spSkeleton_setToSetupPose(skeleton);
}
void SkeletonRenderer::setBonesToSetupPose () {
spSkeleton_setBonesToSetupPose(skeleton);
}
void SkeletonRenderer::setSlotsToSetupPose () {
spSkeleton_setSlotsToSetupPose(skeleton);
}
spBone* SkeletonRenderer::findBone (const char* boneName) const {
return spSkeleton_findBone(skeleton, boneName);
}
spSlot* SkeletonRenderer::findSlot (const char* slotName) const {
return spSkeleton_findSlot(skeleton, slotName);
}
bool SkeletonRenderer::setSkin (const char* skinName) {
return spSkeleton_setSkinByName(skeleton, skinName) ? true : false;
}
spAttachment* SkeletonRenderer::getAttachment (const char* slotName, const char* attachmentName) const {
return spSkeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
}
bool SkeletonRenderer::setAttachment (const char* slotName, const char* attachmentName) {
return spSkeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
}
// --- CCBlendProtocol
const BlendFunc& SkeletonRenderer::getBlendFunc () const {
return blendFunc;
}
void SkeletonRenderer::setBlendFunc (const BlendFunc &blendFunc) {
this->blendFunc = blendFunc;
}
void SkeletonRenderer::setOpacityModifyRGB (bool value) {
premultipliedAlpha = value;
}
bool SkeletonRenderer::isOpacityModifyRGB () {
return premultipliedAlpha;
}
}

View File

@ -0,0 +1,113 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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_SKELETONRENDERER_H_
#define SPINE_SKELETONRENDERER_H_
#include <spine/spine.h>
#include "cocos2d.h"
namespace spine {
class PolygonBatch;
/** Draws a skeleton. */
class SkeletonRenderer: public cocos2d::NodeRGBA, public cocos2d::BlendProtocol {
public:
spSkeleton* skeleton;
spBone* rootBone;
float timeScale;
bool debugSlots;
bool debugBones;
bool premultipliedAlpha;
static SkeletonRenderer* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
static SkeletonRenderer* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
static SkeletonRenderer* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
SkeletonRenderer (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
SkeletonRenderer (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
SkeletonRenderer (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
virtual ~SkeletonRenderer ();
virtual void update (float deltaTime);
virtual void draw(cocos2d::Renderer* renderer, const kmMat4& transform, bool transformUpdated) override;
virtual void drawSkeleton (const kmMat4& transform, bool transformUpdated);
virtual cocos2d::Rect boundingBox ();
// --- Convenience methods for common Skeleton_* functions.
void updateWorldTransform ();
void setToSetupPose ();
void setBonesToSetupPose ();
void setSlotsToSetupPose ();
/* Returns 0 if the bone was not found. */
spBone* findBone (const char* boneName) const;
/* Returns 0 if the slot was not found. */
spSlot* findSlot (const char* slotName) const;
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
* attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found.
* @param skin May be 0.*/
bool setSkin (const char* skinName);
/* Returns 0 if the slot or attachment was not found. */
spAttachment* getAttachment (const char* slotName, const char* attachmentName) const;
/* Returns false if the slot or attachment was not found. */
bool setAttachment (const char* slotName, const char* attachmentName);
// --- BlendProtocol
virtual void setBlendFunc (const cocos2d::BlendFunc& blendFunc);
virtual const cocos2d::BlendFunc& getBlendFunc () const;
virtual void setOpacityModifyRGB (bool value);
virtual bool isOpacityModifyRGB ();
protected:
SkeletonRenderer ();
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
virtual cocos2d::Texture2D* getTexture (spRegionAttachment* attachment) const;
virtual cocos2d::Texture2D* getTexture (spMeshAttachment* attachment) const;
virtual cocos2d::Texture2D* getTexture (spSkinnedMeshAttachment* attachment) const;
private:
bool ownsSkeletonData;
spAtlas* atlas;
cocos2d::CustomCommand drawCommand;
cocos2d::BlendFunc blendFunc;
PolygonBatch* batch;
float* worldVertices;
void initialize ();
};
}
#endif /* SPINE_SKELETONRENDERER_H_ */

View File

@ -0,0 +1,39 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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_COCOS2DX_H_
#define SPINE_COCOS2DX_H_
#include <spine/spine.h>
#include "cocos2d.h"
#include <spine/SkeletonRenderer.h>
#include <spine/SkeletonAnimation.h>
#endif /* SPINE_COCOS2DX_H_ */

View File

@ -0,0 +1,16 @@
# spine-cocos2dx v3.1
The spine-cocos2dx runtime provides functionality to load, manipulate and render [Spine](http://esotericsoftware.com) skeletal animation data using [cocos2d-x](http://www.cocos2d-x.org/). spine-cocos2dx is based on [spine-c](https://github.com/EsotericSoftware/spine-runtimes/tree/master/spine-c).
## Setup
1. Download the Spine Runtimes source using [git](https://help.github.com/articles/set-up-git) or by downloading it [as a zip](https://github.com/EsotericSoftware/spine-runtimes/archive/master.zip).
1. Place the contents of a cocos2d-x version 3.1 distribution into the `spine-cocos2dx/cocos2dx` directory.
1. Run the `python download-deps.py` script in the `spine-cocos2dx/cocos2dx` directory.
1. Open the XCode (Mac) or Visual C++ 2012 Express (Windows) project file from the `spine-cocos2dx/example` directory. Build files are also provided for Android.
Alternatively, the contents of the `spine-c/src`, `spine-c/include` and `spine-cocos2dx/src` directories can be copied into your project. Be sure your header search path will find the contents of the `spine-c/include` and `spine-cocos2dx/src` directories. Note that the includes use `spine/Xxx.h`, so the `spine` directory cannot be omitted when copying the files.
## Examples
[Simple example](https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-cocos2dx/example/Classes/ExampleLayer.cpp#L18)

View File

@ -0,0 +1,87 @@
#include "AppDelegate.h"
#include <vector>
#include <string>
#include "SpineboyExample.h"
#include "AppMacros.h"
USING_NS_CC;
using namespace std;
AppDelegate::AppDelegate () {
}
AppDelegate::~AppDelegate () {
}
bool AppDelegate::applicationDidFinishLaunching () {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
// Set the design resolution
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// a bug in DirectX 11 level9-x on the device prevents ResolutionPolicy::NO_BORDER from working correctly
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::SHOW_ALL);
#else
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
#endif
Size frameSize = glview->getFrameSize();
vector<string> searchPath;
// In this demo, we select resource according to the frame's height.
// If the resource size is different from design resolution size, you need to set contentScaleFactor.
// We use the ratio of resource's height to the height of design resolution,
// this can make sure that the resource's height could fit for the height of design resolution.
if (frameSize.height > mediumResource.size.height) {
// if the frame's height is larger than the height of medium resource size, select large resource.
searchPath.push_back(largeResource.directory);
director->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
} else if (frameSize.height > smallResource.size.height) {
// if the frame's height is larger than the height of small resource size, select medium resource.
searchPath.push_back(mediumResource.directory);
director->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
} else {
// if the frame's height is smaller than the height of medium resource size, select small resource.
searchPath.push_back(smallResource.directory);
director->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
}
searchPath.push_back("common");
// set searching path
FileUtils::getInstance()->setSearchPaths(searchPath);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
auto scene = SpineboyExample::scene();
// run
director->runWithScene(scene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground () {
Director::getInstance()->stopAnimation();
// if you use SimpleAudioEngine, it must be paused
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground () {
Director::getInstance()->startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -0,0 +1,18 @@
#ifndef _APPDELEGATE_H_
#define _APPDELEGATE_H_
#include "cocos2d.h"
class AppDelegate: private cocos2d::CCApplication {
public:
AppDelegate ();
virtual ~AppDelegate ();
virtual bool applicationDidFinishLaunching ();
virtual void applicationDidEnterBackground ();
virtual void applicationWillEnterForeground ();
};
#endif // _APPDELEGATE_H_

View File

@ -0,0 +1,61 @@
#ifndef _APPMACROS_H_
#define _APPMACROS_H_
#include "cocos2d.h"
/* For demonstrating using one design resolution to match different resources,
or one resource to match different design resolutions.
[Situation 1] Using one design resolution to match different resources.
Please look into Appdelegate::applicationDidFinishLaunching.
We check current device frame size to decide which resource need to be selected.
So if you want to test this situation which said in title '[Situation 1]',
you should change ios simulator to different device(e.g. iphone, iphone-retina3.5, iphone-retina4.0, ipad, ipad-retina),
or change the window size in "proj.XXX/main.cpp" by "CCEGLView::setFrameSize" if you are using win32 or linux plaform
and modify "proj.mac/AppController.mm" by changing the window rectangle.
[Situation 2] Using one resource to match different design resolutions.
The coordinates in your codes is based on your current design resolution rather than resource size.
Therefore, your design resolution could be very large and your resource size could be small.
To test this, just define the marco 'TARGET_DESIGN_RESOLUTION_SIZE' to 'DESIGN_RESOLUTION_2048X1536'
and open iphone simulator or create a window of 480x320 size.
[Note] Normally, developer just need to define one design resolution(e.g. 960x640) with one or more resources.
*/
#define DESIGN_RESOLUTION_480X320 0
#define DESIGN_RESOLUTION_960x640 1
#define DESIGN_RESOLUTION_1024X768 2
#define DESIGN_RESOLUTION_2048X1536 3
/* If you want to switch design resolution, change next line */
#define TARGET_DESIGN_RESOLUTION_SIZE DESIGN_RESOLUTION_960x640
typedef struct tagResource {
cocos2d::Size size;
char directory[100];
} Resource;
static Resource smallResource = {cocos2d::Size(480, 320), "iphone"};
static Resource mediumResource = {cocos2d::Size(960, 640), "iphone-retina"};
static Resource largeResource = {cocos2d::Size(1024, 768), "ipad"};
static Resource extralargeResource = {cocos2d::Size(2048, 1536), "ipad-retina"};
#if (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_480X320)
static cocos2d::CCSize designResolutionSize = cocos2d::Size(480, 320);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_960x640)
static cocos2d::CCSize designResolutionSize = cocos2d::Size(960, 640);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_1024X768)
static cocos2d::CCSize designResolutionSize = cocos2d::Size(1024, 768);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_2048X1536)
static cocos2d::CCSize designResolutionSize = cocos2d::Size(2048, 1536);
#else
#error unknown target design resolution!
#endif
// The font size 24 is designed for small resolution, so we should change it to fit for current design resolution
#define TITLE_FONT_SIZE (cocos2d::Director::getInstance()->getOpenGLView()->getDesignResolutionSize().width / smallResource.size.width * 24)
#endif /* _APPMACROS_H_ */

View File

@ -0,0 +1,73 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 "GoblinsExample.h"
#include "SpineboyExample.h"
#include <iostream>
#include <fstream>
#include <string.h>
USING_NS_CC;
using namespace spine;
using namespace std;
Scene* GoblinsExample::scene () {
Scene *scene = Scene::create();
scene->addChild(GoblinsExample::create());
return scene;
}
bool GoblinsExample::init () {
if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
skeletonNode = SkeletonAnimation::createWithFile("goblins-ffd.json", "goblins-ffd.atlas", 1.5f);
skeletonNode->setAnimation(0, "walk", true);
skeletonNode->setSkin("goblin");
Size windowSize = Director::getInstance()->getWinSize();
skeletonNode->setPosition(Vector2(windowSize.width / 2, 20));
addChild(skeletonNode);
scheduleUpdate();
EventListenerTouchOneByOne* listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [this] (Touch* touch, Event* event) -> bool {
if (!skeletonNode->debugBones)
skeletonNode->debugBones = true;
else if (skeletonNode->timeScale == 1)
skeletonNode->timeScale = 0.3f;
else
Director::getInstance()->replaceScene(SpineboyExample::scene());
return true;
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}

View File

@ -0,0 +1,48 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 _GOBLINSEXAMPLE_H_
#define _GOBLINSEXAMPLE_H_
#include "cocos2d.h"
#include <spine/spine-cocos2dx.h>
class GoblinsExample : public cocos2d::LayerColor {
public:
static cocos2d::Scene* scene ();
virtual bool init ();
CREATE_FUNC (GoblinsExample);
private:
spine::SkeletonAnimation* skeletonNode;
};
#endif // _GOBLINSEXAMPLE_H_

View File

@ -0,0 +1,105 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 "SpineboyExample.h"
#include "GoblinsExample.h"
#include <iostream>
#include <fstream>
#include <string.h>
USING_NS_CC;
using namespace spine;
using namespace std;
Scene* SpineboyExample::scene () {
Scene *scene = Scene::create();
scene->addChild(SpineboyExample::create());
return scene;
}
bool SpineboyExample::init () {
if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
skeletonNode = SkeletonAnimation::createWithFile("spineboy.json", "spineboy.atlas", 0.6f);
skeletonNode->startListener = [this] (int trackIndex) {
spTrackEntry* entry = spAnimationState_getCurrent(skeletonNode->state, trackIndex);
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
log("%d start: %s", trackIndex, animationName);
};
skeletonNode->endListener = [] (int trackIndex) {
log("%d end", trackIndex);
};
skeletonNode->completeListener = [] (int trackIndex, int loopCount) {
log("%d complete: %d", trackIndex, loopCount);
};
skeletonNode->eventListener = [] (int trackIndex, spEvent* event) {
log("%d event: %s, %d, %f, %s", trackIndex, event->data->name, event->intValue, event->floatValue, event->stringValue);
};
skeletonNode->setMix("walk", "jump", 0.2f);
skeletonNode->setMix("jump", "run", 0.2f);
skeletonNode->setAnimation(0, "walk", true);
spTrackEntry* jumpEntry = skeletonNode->addAnimation(0, "jump", false, 3);
skeletonNode->addAnimation(0, "run", true);
skeletonNode->setStartListener(jumpEntry, [] (int trackIndex) {
log("jumped!", trackIndex);
});
// skeletonNode->addAnimation(1, "test", true);
// skeletonNode->runAction(RepeatForever::create(Sequence::create(FadeOut::create(1), FadeIn::create(1), DelayTime::create(5), NULL)));
Size windowSize = Director::getInstance()->getWinSize();
skeletonNode->setPosition(Vector2(windowSize.width / 2, 20));
addChild(skeletonNode);
scheduleUpdate();
EventListenerTouchOneByOne* listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [this] (Touch* touch, Event* event) -> bool {
if (!skeletonNode->debugBones)
skeletonNode->debugBones = true;
else if (skeletonNode->timeScale == 1)
skeletonNode->timeScale = 0.3f;
else
Director::getInstance()->replaceScene(GoblinsExample::scene());
return true;
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}
void SpineboyExample::update (float deltaTime) {
// Test releasing memory.
// Director::getInstance()->replaceScene(SpineboyExample::scene());
}

View File

@ -0,0 +1,49 @@
/******************************************************************************
* Spine Runtimes Software License
* Version 2.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to install, execute and perform the Spine Runtimes
* Software (the "Software") solely for internal use. Without the written
* permission of Esoteric Software (typically granted by licensing Spine), you
* may not (a) modify, translate, adapt or otherwise create derivative works,
* improvements of the Software or develop new applications using the Software
* or (b) remove, delete, alter or obscure any trademarks or any copyright,
* trademark, patent or other intellectual property or proprietary rights
* notices on or in the Software, including any copy thereof. Redistributions
* in binary or source form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 ESOTERIC SOFTARE 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 _SPINEBOYEXAMPLE_H_
#define _SPINEBOYEXAMPLE_H_
#include "cocos2d.h"
#include <spine/spine-cocos2dx.h>
class SpineboyExample : public cocos2d::LayerColor {
public:
static cocos2d::Scene* scene ();
virtual bool init ();
virtual void update (float deltaTime);
CREATE_FUNC (SpineboyExample);
private:
spine::SkeletonAnimation* skeletonNode;
};
#endif // _SPINEBOYEXAMPLE_H_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1,292 @@
goblins-ffd.png
format: RGBA8888
filter: Linear,Linear
repeat: none
dagger
rotate: false
xy: 2, 28
size: 26, 108
orig: 26, 108
offset: 0, 0
index: -1
goblin/eyes-closed
rotate: false
xy: 137, 29
size: 34, 12
orig: 34, 12
offset: 0, 0
index: -1
goblin/head
rotate: false
xy: 26, 357
size: 103, 66
orig: 103, 66
offset: 0, 0
index: -1
goblin/left-arm
rotate: false
xy: 30, 28
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblin/left-foot
rotate: false
xy: 134, 260
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblin/left-hand
rotate: false
xy: 69, 25
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/left-lower-leg
rotate: false
xy: 134, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblin/left-shoulder
rotate: false
xy: 137, 43
size: 29, 44
orig: 29, 44
offset: 0, 0
index: -1
goblin/left-upper-leg
rotate: false
xy: 30, 65
size: 33, 73
orig: 33, 73
offset: 0, 0
index: -1
goblin/neck
rotate: false
xy: 201, 387
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/pelvis
rotate: false
xy: 26, 140
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblin/right-arm
rotate: false
xy: 171, 84
size: 23, 50
orig: 23, 50
offset: 0, 0
index: -1
goblin/right-foot
rotate: false
xy: 134, 225
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblin/right-hand
rotate: false
xy: 204, 258
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblin/right-lower-leg
rotate: false
xy: 201, 430
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblin/right-shoulder
rotate: false
xy: 130, 89
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblin/right-upper-leg
rotate: false
xy: 98, 214
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblin/torso
rotate: false
xy: 131, 410
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblin/undie-straps
rotate: false
xy: 2, 7
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblin/undies
rotate: false
xy: 199, 227
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
goblingirl/eyes-closed
rotate: false
xy: 59, 2
size: 37, 21
orig: 37, 21
offset: 0, 0
index: -1
goblingirl/head
rotate: false
xy: 26, 425
size: 103, 81
orig: 103, 81
offset: 0, 0
index: -1
goblingirl/left-arm
rotate: false
xy: 201, 190
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblingirl/left-foot
rotate: false
xy: 134, 192
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblingirl/left-hand
rotate: false
xy: 196, 109
size: 35, 40
orig: 35, 40
offset: 0, 0
index: -1
goblingirl/left-lower-leg
rotate: false
xy: 169, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/left-shoulder
rotate: false
xy: 107, 30
size: 28, 46
orig: 28, 46
offset: 0, 0
index: -1
goblingirl/left-upper-leg
rotate: false
xy: 65, 68
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/neck
rotate: false
xy: 204, 297
size: 35, 41
orig: 35, 41
offset: 0, 0
index: -1
goblingirl/pelvis
rotate: false
xy: 131, 365
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblingirl/right-arm
rotate: false
xy: 100, 97
size: 28, 50
orig: 28, 50
offset: 0, 0
index: -1
goblingirl/right-foot
rotate: false
xy: 134, 157
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblingirl/right-hand
rotate: false
xy: 199, 151
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblingirl/right-lower-leg
rotate: false
xy: 96, 279
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblingirl/right-shoulder
rotate: false
xy: 204, 340
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblingirl/right-upper-leg
rotate: false
xy: 98, 149
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblingirl/torso
rotate: false
xy: 26, 259
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblingirl/undie-straps
rotate: false
xy: 134, 136
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblingirl/undies
rotate: false
xy: 196, 78
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
shield
rotate: false
xy: 26, 185
size: 70, 72
orig: 70, 72
offset: 0, 0
index: -1
spear
rotate: false
xy: 2, 138
size: 22, 368
orig: 22, 368
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@ -0,0 +1,194 @@
spineboy.png
format: RGBA8888
filter: Linear,Linear
repeat: none
eye_indifferent
rotate: true
xy: 389, 5
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
eye_surprised
rotate: false
xy: 580, 34
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
front_bracer
rotate: false
xy: 732, 85
size: 35, 48
orig: 35, 48
offset: 0, 0
index: -1
front_fist_closed
rotate: false
xy: 556, 91
size: 45, 49
orig: 45, 49
offset: 0, 0
index: -1
front_fist_open
rotate: false
xy: 668, 32
size: 52, 52
orig: 52, 52
offset: 0, 0
index: -1
front_foot
rotate: false
xy: 924, 201
size: 76, 41
orig: 76, 41
offset: 0, 0
index: -1
front_foot_bend1
rotate: false
xy: 845, 200
size: 77, 42
orig: 77, 42
offset: 0, 0
index: -1
front_foot_bend2
rotate: false
xy: 778, 186
size: 65, 56
orig: 65, 56
offset: 0, 0
index: -1
front_shin
rotate: true
xy: 444, 91
size: 49, 110
orig: 49, 110
offset: 0, 0
index: -1
front_thigh
rotate: true
xy: 603, 89
size: 29, 67
orig: 29, 67
offset: 0, 0
index: -1
front_upper_arm
rotate: true
xy: 672, 86
size: 32, 58
orig: 32, 58
offset: 0, 0
index: -1
goggles
rotate: false
xy: 444, 142
size: 157, 100
orig: 157, 100
offset: 0, 0
index: -1
gun
rotate: false
xy: 603, 120
size: 126, 122
orig: 126, 122
offset: 0, 0
index: -1
head
rotate: false
xy: 279, 63
size: 163, 179
orig: 163, 179
offset: 0, 0
index: -1
mouth_grind
rotate: false
xy: 845, 163
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_oooo
rotate: false
xy: 842, 126
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_smile
rotate: false
xy: 769, 97
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
muzzle
rotate: false
xy: 2, 2
size: 275, 240
orig: 277, 240
offset: 0, 0
index: -1
neck
rotate: false
xy: 903, 173
size: 22, 25
orig: 22, 25
offset: 0, 0
index: -1
rear_bracer
rotate: false
xy: 722, 40
size: 34, 43
orig: 34, 43
offset: 0, 0
index: -1
rear_foot
rotate: false
xy: 444, 11
size: 68, 36
orig: 68, 36
offset: 0, 0
index: -1
rear_foot_bend1
rotate: false
xy: 444, 49
size: 70, 40
orig: 70, 40
offset: 0, 0
index: -1
rear_foot_bend2
rotate: false
xy: 778, 134
size: 62, 50
orig: 62, 50
offset: 0, 0
index: -1
rear_shin
rotate: false
xy: 731, 135
size: 45, 107
orig: 45, 107
offset: 0, 0
index: -1
rear_thigh
rotate: true
xy: 516, 50
size: 39, 62
orig: 39, 62
offset: 0, 0
index: -1
rear_upper_arm
rotate: false
xy: 638, 35
size: 28, 52
orig: 28, 52
offset: 0, 0
index: -1
torso
rotate: true
xy: 279, 2
size: 59, 108
orig: 59, 108
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

View File

@ -0,0 +1,292 @@
goblins-ffd.png
format: RGBA8888
filter: Linear,Linear
repeat: none
dagger
rotate: false
xy: 2, 28
size: 26, 108
orig: 26, 108
offset: 0, 0
index: -1
goblin/eyes-closed
rotate: false
xy: 137, 29
size: 34, 12
orig: 34, 12
offset: 0, 0
index: -1
goblin/head
rotate: false
xy: 26, 357
size: 103, 66
orig: 103, 66
offset: 0, 0
index: -1
goblin/left-arm
rotate: false
xy: 30, 28
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblin/left-foot
rotate: false
xy: 134, 260
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblin/left-hand
rotate: false
xy: 69, 25
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/left-lower-leg
rotate: false
xy: 134, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblin/left-shoulder
rotate: false
xy: 137, 43
size: 29, 44
orig: 29, 44
offset: 0, 0
index: -1
goblin/left-upper-leg
rotate: false
xy: 30, 65
size: 33, 73
orig: 33, 73
offset: 0, 0
index: -1
goblin/neck
rotate: false
xy: 201, 387
size: 36, 41
orig: 36, 41
offset: 0, 0
index: -1
goblin/pelvis
rotate: false
xy: 26, 140
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblin/right-arm
rotate: false
xy: 171, 84
size: 23, 50
orig: 23, 50
offset: 0, 0
index: -1
goblin/right-foot
rotate: false
xy: 134, 225
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblin/right-hand
rotate: false
xy: 204, 258
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblin/right-lower-leg
rotate: false
xy: 201, 430
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblin/right-shoulder
rotate: false
xy: 130, 89
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblin/right-upper-leg
rotate: false
xy: 98, 214
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblin/torso
rotate: false
xy: 131, 410
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblin/undie-straps
rotate: false
xy: 2, 7
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblin/undies
rotate: false
xy: 199, 227
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
goblingirl/eyes-closed
rotate: false
xy: 59, 2
size: 37, 21
orig: 37, 21
offset: 0, 0
index: -1
goblingirl/head
rotate: false
xy: 26, 425
size: 103, 81
orig: 103, 81
offset: 0, 0
index: -1
goblingirl/left-arm
rotate: false
xy: 201, 190
size: 37, 35
orig: 37, 35
offset: 0, 0
index: -1
goblingirl/left-foot
rotate: false
xy: 134, 192
size: 65, 31
orig: 65, 31
offset: 0, 0
index: -1
goblingirl/left-hand
rotate: false
xy: 196, 109
size: 35, 40
orig: 35, 40
offset: 0, 0
index: -1
goblingirl/left-lower-leg
rotate: false
xy: 169, 293
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/left-shoulder
rotate: false
xy: 107, 30
size: 28, 46
orig: 28, 46
offset: 0, 0
index: -1
goblingirl/left-upper-leg
rotate: false
xy: 65, 68
size: 33, 70
orig: 33, 70
offset: 0, 0
index: -1
goblingirl/neck
rotate: false
xy: 204, 297
size: 35, 41
orig: 35, 41
offset: 0, 0
index: -1
goblingirl/pelvis
rotate: false
xy: 131, 365
size: 62, 43
orig: 62, 43
offset: 0, 0
index: -1
goblingirl/right-arm
rotate: false
xy: 100, 97
size: 28, 50
orig: 28, 50
offset: 0, 0
index: -1
goblingirl/right-foot
rotate: false
xy: 134, 157
size: 63, 33
orig: 63, 33
offset: 0, 0
index: -1
goblingirl/right-hand
rotate: false
xy: 199, 151
size: 36, 37
orig: 36, 37
offset: 0, 0
index: -1
goblingirl/right-lower-leg
rotate: false
xy: 96, 279
size: 36, 76
orig: 36, 76
offset: 0, 0
index: -1
goblingirl/right-shoulder
rotate: false
xy: 204, 340
size: 39, 45
orig: 39, 45
offset: 0, 0
index: -1
goblingirl/right-upper-leg
rotate: false
xy: 98, 149
size: 34, 63
orig: 34, 63
offset: 0, 0
index: -1
goblingirl/torso
rotate: false
xy: 26, 259
size: 68, 96
orig: 68, 96
offset: 0, 0
index: -1
goblingirl/undie-straps
rotate: false
xy: 134, 136
size: 55, 19
orig: 55, 19
offset: 0, 0
index: -1
goblingirl/undies
rotate: false
xy: 196, 78
size: 36, 29
orig: 36, 29
offset: 0, 0
index: -1
shield
rotate: false
xy: 26, 185
size: 70, 72
orig: 70, 72
offset: 0, 0
index: -1
spear
rotate: false
xy: 2, 138
size: 22, 368
orig: 22, 368
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@ -0,0 +1,194 @@
spineboy.png
format: RGBA8888
filter: Linear,Linear
repeat: none
eye_indifferent
rotate: true
xy: 389, 5
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
eye_surprised
rotate: false
xy: 580, 34
size: 56, 53
orig: 56, 53
offset: 0, 0
index: -1
front_bracer
rotate: false
xy: 732, 85
size: 35, 48
orig: 35, 48
offset: 0, 0
index: -1
front_fist_closed
rotate: false
xy: 556, 91
size: 45, 49
orig: 45, 49
offset: 0, 0
index: -1
front_fist_open
rotate: false
xy: 668, 32
size: 52, 52
orig: 52, 52
offset: 0, 0
index: -1
front_foot
rotate: false
xy: 924, 201
size: 76, 41
orig: 76, 41
offset: 0, 0
index: -1
front_foot_bend1
rotate: false
xy: 845, 200
size: 77, 42
orig: 77, 42
offset: 0, 0
index: -1
front_foot_bend2
rotate: false
xy: 778, 186
size: 65, 56
orig: 65, 56
offset: 0, 0
index: -1
front_shin
rotate: true
xy: 444, 91
size: 49, 110
orig: 49, 110
offset: 0, 0
index: -1
front_thigh
rotate: true
xy: 603, 89
size: 29, 67
orig: 29, 67
offset: 0, 0
index: -1
front_upper_arm
rotate: true
xy: 672, 86
size: 32, 58
orig: 32, 58
offset: 0, 0
index: -1
goggles
rotate: false
xy: 444, 142
size: 157, 100
orig: 157, 100
offset: 0, 0
index: -1
gun
rotate: false
xy: 603, 120
size: 126, 122
orig: 126, 122
offset: 0, 0
index: -1
head
rotate: false
xy: 279, 63
size: 163, 179
orig: 163, 179
offset: 0, 0
index: -1
mouth_grind
rotate: false
xy: 845, 163
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_oooo
rotate: false
xy: 842, 126
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
mouth_smile
rotate: false
xy: 769, 97
size: 56, 35
orig: 56, 35
offset: 0, 0
index: -1
muzzle
rotate: false
xy: 2, 2
size: 275, 240
orig: 277, 240
offset: 0, 0
index: -1
neck
rotate: false
xy: 903, 173
size: 22, 25
orig: 22, 25
offset: 0, 0
index: -1
rear_bracer
rotate: false
xy: 722, 40
size: 34, 43
orig: 34, 43
offset: 0, 0
index: -1
rear_foot
rotate: false
xy: 444, 11
size: 68, 36
orig: 68, 36
offset: 0, 0
index: -1
rear_foot_bend1
rotate: false
xy: 444, 49
size: 70, 40
orig: 70, 40
offset: 0, 0
index: -1
rear_foot_bend2
rotate: false
xy: 778, 134
size: 62, 50
orig: 62, 50
offset: 0, 0
index: -1
rear_shin
rotate: false
xy: 731, 135
size: 45, 107
orig: 45, 107
offset: 0, 0
index: -1
rear_thigh
rotate: true
xy: 516, 50
size: 39, 62
orig: 39, 62
offset: 0, 0
index: -1
rear_upper_arm
rotate: false
xy: 638, 35
size: 28, 52
orig: 28, 52
offset: 0, 0
index: -1
torso
rotate: true
xy: 279, 2
size: 59, 108
orig: 59, 108
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Some files were not shown because too many files have changed in this diff Show More