cocos2d-x runtime!

This commit is contained in:
NathanSweet 2013-03-22 16:18:18 +01:00
parent 3aab744395
commit 17394e1851
27 changed files with 1875 additions and 0 deletions

10
spine-cocos2dx/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
*Debug.win32*
*.sdf
*.opensdf
*.user
*.suo
cocos2dx
spine-cocos2dx/include/spine/*
spine-cocos2dx/include/json/*
spine-cocos2dx/src/spine/*
spine-cocos2dx/src/json/*

View File

@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2012 for Windows Desktop
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spine-cocos2dx", "spine-cocos2dx\proj.win32\spine-cocos2dx.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.ActiveCfg = Debug|Win32
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.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
EndGlobal

View File

@ -0,0 +1,98 @@
{
"bones": [
{ "name": "root", "length": 0 },
{ "name": "hip", "parent": "root", "length": 0, "x": 0.64, "y": 114.41 },
{ "name": "left upper leg", "parent": "hip", "length": 50.39, "x": 14.45, "y": 2.81, "rotation": -89.09 },
{ "name": "left lower leg", "parent": "left upper leg", "length": 56.45, "x": 51.78, "y": 3.46, "rotation": -16.65 },
{ "name": "left foot", "parent": "left lower leg", "length": 46.5, "x": 64.02, "y": -8.67, "rotation": 102.43 },
{ "name": "right upper leg", "parent": "hip", "length": 45.76, "x": -18.27, "rotation": -101.13 },
{ "name": "right lower leg", "parent": "right upper leg", "length": 58.52, "x": 50.21, "y": 0.6, "rotation": -10.7 },
{ "name": "right foot", "parent": "right lower leg", "length": 45.45, "x": 64.88, "y": 0.04, "rotation": 110.3 },
{ "name": "torso", "parent": "hip", "length": 85.82, "x": -6.42, "y": 1.97, "rotation": 94.95 },
{ "name": "neck", "parent": "torso", "length": 18.38, "x": 83.64, "y": -1.78, "rotation": 0.9 },
{ "name": "head", "parent": "neck", "length": 68.28, "x": 19.09, "y": 6.97, "rotation": -8.94 },
{ "name": "right shoulder", "parent": "torso", "length": 49.95, "x": 81.9, "y": 6.79, "rotation": 130.6 },
{ "name": "right arm", "parent": "right shoulder", "length": 36.74, "x": 49.95, "y": -0.12, "rotation": 40.12 },
{ "name": "right hand", "parent": "right arm", "length": 15.32, "x": 36.9, "y": 0.34, "rotation": 2.35 },
{ "name": "left shoulder", "parent": "torso", "length": 44.19, "x": 78.96, "y": -15.75, "rotation": -156.96 },
{ "name": "left arm", "parent": "left shoulder", "length": 35.62, "x": 44.19, "y": -0.01, "rotation": 28.16 },
{ "name": "left hand", "parent": "left arm", "length": 11.52, "x": 35.62, "y": 0.07, "rotation": 2.7 },
{ "name": "pelvis", "parent": "hip", "length": 0, "x": 1.41, "y": -6.57 }
],
"slots": [
{ "name": "template", "bone": "root", "color": "ff898c86" },
{ "name": "left shoulder", "bone": "left shoulder", "attachment": "left-shoulder" },
{ "name": "left arm", "bone": "left arm", "attachment": "left-arm" },
{ "name": "left hand", "bone": "left hand", "attachment": "left-hand" },
{ "name": "left foot", "bone": "left foot", "attachment": "left-foot" },
{ "name": "left lower leg", "bone": "left lower leg", "attachment": "left-lower-leg" },
{ "name": "left upper leg", "bone": "left upper leg", "attachment": "left-upper-leg" },
{ "name": "pelvis", "bone": "pelvis", "attachment": "pelvis" },
{ "name": "right foot", "bone": "right foot", "attachment": "right-foot" },
{ "name": "right lower leg", "bone": "right lower leg", "attachment": "right-lower-leg" },
{ "name": "right upper leg", "bone": "right upper leg", "attachment": "right-upper-leg" },
{ "name": "torso", "bone": "torso", "attachment": "torso" },
{ "name": "neck", "bone": "neck", "attachment": "neck" },
{ "name": "head", "bone": "head", "attachment": "head" },
{ "name": "eyes", "bone": "head", "attachment": "eyes" },
{ "name": "right shoulder", "bone": "right shoulder", "attachment": "right-shoulder" },
{ "name": "right arm", "bone": "right arm", "attachment": "right-arm" },
{ "name": "right hand", "bone": "right hand", "attachment": "right-hand" }
],
"skins": {
"default": {
"left shoulder": {
"left-shoulder": { "x": 23.74, "y": 0.11, "rotation": 62.01, "width": 34, "height": 53 }
},
"left arm": {
"left-arm": { "x": 15.11, "y": -0.44, "rotation": 33.84, "width": 35, "height": 29 }
},
"left hand": {
"left-hand": { "x": 0.75, "y": 1.86, "rotation": 31.14, "width": 35, "height": 38 }
},
"left foot": {
"left-foot": { "x": 24.35, "y": 8.88, "rotation": 3.32, "width": 65, "height": 30 }
},
"left lower leg": {
"left-lower-leg": { "x": 24.55, "y": -1.92, "rotation": 105.75, "width": 49, "height": 64 }
},
"left upper leg": {
"left-upper-leg": { "x": 26.12, "y": -1.85, "rotation": 89.09, "width": 33, "height": 67 }
},
"pelvis": {
"pelvis": { "x": -4.83, "y": 10.62, "width": 63, "height": 47 }
},
"right foot": {
"right-foot": { "x": 19.02, "y": 8.47, "rotation": 1.52, "width": 67, "height": 30 }
},
"right lower leg": {
"right-lower-leg": { "x": 23.28, "y": -2.59, "rotation": 111.83, "width": 51, "height": 64 }
},
"right upper leg": {
"right-upper-leg": { "x": 23.03, "y": 0.25, "rotation": 101.13, "width": 44, "height": 70 }
},
"torso": {
"torso": { "x": 44.57, "y": -7.08, "rotation": -94.95, "width": 68, "height": 92 }
},
"neck": {
"neck": { "x": 9.42, "y": -3.66, "rotation": -100.15, "width": 34, "height": 28 }
},
"head": {
"head": { "x": 53.94, "y": -5.75, "rotation": -86.9, "width": 121, "height": 132 }
},
"eyes": {
"eyes": { "x": 28.94, "y": -32.92, "rotation": -86.9, "width": 34, "height": 27 },
"eyes-closed": { "x": 28.77, "y": -32.86, "rotation": -86.9, "width": 34, "height": 27 }
},
"right shoulder": {
"right-shoulder": { "x": 25.86, "y": 0.03, "rotation": 134.44, "width": 52, "height": 51 }
},
"right arm": {
"right-arm": { "x": 18.34, "y": -2.64, "rotation": 94.32, "width": 21, "height": 45 }
},
"right hand": {
"right-hand": { "x": 6.82, "y": 1.25, "rotation": 91.96, "width": 32, "height": 32 }
}
}
}
}

View File

@ -0,0 +1,278 @@
{
"bones": {
"left upper leg": {
"rotate": [
{ "time": 0, "angle": -26.55 },
{ "time": 0.1333, "angle": -8.78 },
{ "time": 0.2666, "angle": 9.51 },
{ "time": 0.4, "angle": 30.74 },
{ "time": 0.5333, "angle": 25.33 },
{ "time": 0.6666, "angle": 26.11 },
{ "time": 0.8, "angle": -7.7 },
{ "time": 0.9333, "angle": -21.19 },
{ "time": 1.0666, "angle": -26.55 }
],
"translate": [
{ "time": 0, "x": -3, "y": -2.25 },
{ "time": 0.4, "x": -2.18, "y": -2.25 },
{ "time": 1.0666, "x": -3, "y": -2.25 }
]
},
"right upper leg": {
"rotate": [
{ "time": 0, "angle": 42.45 },
{ "time": 0.1333, "angle": 52.1 },
{ "time": 0.2666, "angle": 5.96 },
{ "time": 0.5333, "angle": -16.93 },
{ "time": 0.6666, "angle": 1.89 },
{
"time": 0.8,
"angle": 28.06,
"curve": [ 0.462, 0.11, 1, 1 ]
},
{
"time": 0.9333,
"angle": 58.68,
"curve": [ 0.5, 0.02, 1, 1 ]
},
{ "time": 1.0666, "angle": 42.45 }
],
"translate": [
{ "time": 0, "x": 8.11, "y": -2.36 },
{ "time": 0.1333, "x": 10.03, "y": -2.56 },
{ "time": 0.4, "x": 2.76, "y": -2.97 },
{ "time": 0.5333, "x": 2.76, "y": -2.81 },
{ "time": 0.9333, "x": 8.67, "y": -2.54 },
{ "time": 1.0666, "x": 8.11, "y": -2.36 }
]
},
"left lower leg": {
"rotate": [
{ "time": 0, "angle": -10.21 },
{ "time": 0.1333, "angle": -55.64 },
{ "time": 0.2666, "angle": -68.12 },
{ "time": 0.5333, "angle": 5.11 },
{ "time": 0.6666, "angle": -28.29 },
{ "time": 0.8, "angle": 4.08 },
{ "time": 0.9333, "angle": 3.53 },
{ "time": 1.0666, "angle": -10.21 }
]
},
"left foot": {
"rotate": [
{ "time": 0, "angle": -3.69 },
{ "time": 0.1333, "angle": -10.42 },
{ "time": 0.2666, "angle": -17.14 },
{ "time": 0.4, "angle": -2.83 },
{ "time": 0.5333, "angle": -3.87 },
{ "time": 0.6666, "angle": 2.78 },
{ "time": 0.8, "angle": 1.68 },
{ "time": 0.9333, "angle": -8.54 },
{ "time": 1.0666, "angle": -3.69 }
]
},
"right shoulder": {
"rotate": [
{
"time": 0,
"angle": 20.89,
"curve": [ 0.264, 0, 0.75, 1 ]
},
{
"time": 0.1333,
"angle": 3.72,
"curve": [ 0.272, 0, 0.841, 1 ]
},
{ "time": 0.6666, "angle": -278.28 },
{ "time": 1.0666, "angle": 20.89 }
],
"translate": [
{ "time": 0, "x": -7.84, "y": 7.19 },
{ "time": 0.1333, "x": -6.36, "y": 6.42 },
{ "time": 0.6666, "x": -11.07, "y": 5.25 },
{ "time": 1.0666, "x": -7.84, "y": 7.19 }
]
},
"right arm": {
"rotate": [
{
"time": 0,
"angle": -4.02,
"curve": [ 0.267, 0, 0.804, 0.99 ]
},
{
"time": 0.1333,
"angle": -13.99,
"curve": [ 0.341, 0, 1, 1 ]
},
{
"time": 0.6666,
"angle": 36.54,
"curve": [ 0.307, 0, 0.787, 0.99 ]
},
{ "time": 1.0666, "angle": -4.02 }
]
},
"right hand": {
"rotate": [
{ "time": 0, "angle": 22.92 },
{ "time": 0.4, "angle": -8.97 },
{ "time": 0.6666, "angle": 0.51 },
{ "time": 1.0666, "angle": 22.92 }
]
},
"left shoulder": {
"rotate": [
{ "time": 0, "angle": -1.47 },
{ "time": 0.1333, "angle": 13.6 },
{ "time": 0.6666, "angle": 280.74 },
{ "time": 1.0666, "angle": -1.47 }
],
"translate": [
{ "time": 0, "x": -1.76, "y": 0.56 },
{ "time": 0.6666, "x": -2.47, "y": 8.14 },
{ "time": 1.0666, "x": -1.76, "y": 0.56 }
]
},
"left hand": {
"rotate": [
{
"time": 0,
"angle": 11.58,
"curve": [ 0.169, 0.37, 0.632, 1.55 ]
},
{
"time": 0.1333,
"angle": 28.13,
"curve": [ 0.692, 0, 0.692, 0.99 ]
},
{
"time": 0.6666,
"angle": -27.42,
"curve": [ 0.117, 0.41, 0.738, 1.76 ]
},
{ "time": 0.8, "angle": -36.32 },
{ "time": 1.0666, "angle": 11.58 }
]
},
"left arm": {
"rotate": [
{ "time": 0, "angle": -8.27 },
{ "time": 0.1333, "angle": 18.43 },
{ "time": 0.6666, "angle": 0.88 },
{ "time": 1.0666, "angle": -8.27 }
]
},
"torso": {
"rotate": [
{ "time": 0, "angle": -10.28 },
{
"time": 0.1333,
"angle": -15.38,
"curve": [ 0.545, 0, 1, 1 ]
},
{
"time": 0.4,
"angle": -9.78,
"curve": [ 0.58, 0.17, 1, 1 ]
},
{ "time": 0.6666, "angle": -15.75 },
{ "time": 0.9333, "angle": -7.06 },
{ "time": 1.0666, "angle": -10.28 }
],
"translate": [
{ "time": 0, "x": -3.67, "y": 1.68 },
{ "time": 0.1333, "x": -3.67, "y": 0.68 },
{ "time": 0.4, "x": -3.67, "y": 1.97 },
{ "time": 0.6666, "x": -3.67, "y": -0.14 },
{ "time": 1.0666, "x": -3.67, "y": 1.68 }
]
},
"right foot": {
"rotate": [
{ "time": 0, "angle": -5.25 },
{ "time": 0.2666, "angle": -4.08 },
{ "time": 0.4, "angle": -6.45 },
{ "time": 0.5333, "angle": -5.39 },
{ "time": 0.8, "angle": -11.68 },
{ "time": 0.9333, "angle": 0.46 },
{ "time": 1.0666, "angle": -5.25 }
]
},
"right lower leg": {
"rotate": [
{ "time": 0, "angle": -3.39 },
{ "time": 0.1333, "angle": -45.53 },
{ "time": 0.2666, "angle": -2.59 },
{ "time": 0.5333, "angle": -19.53 },
{ "time": 0.6666, "angle": -64.8 },
{
"time": 0.8,
"angle": -82.56,
"curve": [ 0.557, 0.18, 1, 1 ]
},
{ "time": 1.0666, "angle": -3.39 }
]
},
"hip": {
"rotate": [
{ "time": 0, "angle": 0, "curve": "stepped" },
{ "time": 1.0666, "angle": 0 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0 },
{
"time": 0.1333,
"x": 0,
"y": -7.61,
"curve": [ 0.272, 0.86, 1, 1 ]
},
{ "time": 0.4, "x": 0, "y": 8.7 },
{ "time": 0.5333, "x": 0, "y": -0.41 },
{
"time": 0.6666,
"x": 0,
"y": -7.05,
"curve": [ 0.235, 0.89, 1, 1 ]
},
{ "time": 0.8, "x": 0, "y": 2.92 },
{ "time": 0.9333, "x": 0, "y": 6.78 },
{ "time": 1.0666, "x": 0, "y": 0 }
]
},
"neck": {
"rotate": [
{ "time": 0, "angle": 3.6 },
{ "time": 0.1333, "angle": 17.49 },
{ "time": 0.2666, "angle": 6.1 },
{ "time": 0.4, "angle": 3.45 },
{ "time": 0.5333, "angle": 5.17 },
{ "time": 0.6666, "angle": 18.36 },
{ "time": 0.8, "angle": 6.09 },
{ "time": 0.9333, "angle": 2.28 },
{ "time": 1.0666, "angle": 3.6 }
]
},
"head": {
"rotate": [
{
"time": 0,
"angle": 3.6,
"curve": [ 0, 0, 0.704, 1.61 ]
},
{ "time": 0.1666, "angle": -0.2 },
{ "time": 0.2666, "angle": 6.1 },
{ "time": 0.4, "angle": 3.45 },
{
"time": 0.5333,
"angle": 5.17,
"curve": [ 0, 0, 0.704, 1.61 ]
},
{ "time": 0.7, "angle": 1.1 },
{ "time": 0.8, "angle": 6.09 },
{ "time": 0.9333, "angle": 2.28 },
{ "time": 1.0666, "angle": 3.6 }
]
}
}
}

View File

@ -0,0 +1,166 @@
../data/spineboy.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
head
rotate: false
xy: 1, 122
size: 121, 132
orig: 121, 132
offset: 0, 0
index: -1
torso
rotate: false
xy: 1, 28
size: 68, 92
orig: 68, 92
offset: 0, 0
index: -1
left-pant-bottom
rotate: false
xy: 1, 4
size: 44, 22
orig: 44, 22
offset: 0, 0
index: -1
right-pant-bottom
rotate: false
xy: 47, 8
size: 46, 18
orig: 46, 18
offset: 0, 0
index: -1
right-upper-leg
rotate: false
xy: 71, 50
size: 44, 70
orig: 44, 70
offset: 0, 0
index: -1
pelvis
rotate: false
xy: 95, 1
size: 63, 47
orig: 63, 47
offset: 0, 0
index: -1
left-upper-leg
rotate: false
xy: 117, 53
size: 33, 67
orig: 33, 67
offset: 0, 0
index: -1
right-foot
rotate: false
xy: 160, 224
size: 67, 30
orig: 67, 30
offset: 0, 0
index: -1
left-shoulder
rotate: false
xy: 124, 201
size: 34, 53
orig: 34, 53
offset: 0, 0
index: -1
left-ankle
rotate: false
xy: 229, 222
size: 25, 32
orig: 25, 32
offset: 0, 0
index: -1
left-foot
rotate: false
xy: 160, 192
size: 65, 30
orig: 65, 30
offset: 0, 0
index: -1
neck
rotate: false
xy: 124, 171
size: 34, 28
orig: 34, 28
offset: 0, 0
index: -1
right-arm
rotate: false
xy: 124, 124
size: 21, 45
orig: 21, 45
offset: 0, 0
index: -1
right-ankle
rotate: false
xy: 227, 190
size: 25, 30
orig: 25, 30
offset: 0, 0
index: -1
left-hand
rotate: false
xy: 147, 131
size: 35, 38
orig: 35, 38
offset: 0, 0
index: -1
left-arm
rotate: false
xy: 184, 161
size: 35, 29
orig: 35, 29
offset: 0, 0
index: -1
eyes-closed
rotate: false
xy: 221, 161
size: 34, 27
orig: 34, 27
offset: 0, 0
index: -1
right-lower-leg
rotate: false
xy: 152, 65
size: 51, 64
orig: 51, 64
offset: 0, 0
index: -1
right-foot-idle
rotate: false
xy: 184, 131
size: 53, 28
orig: 53, 28
offset: 0, 0
index: -1
left-lower-leg
rotate: false
xy: 205, 65
size: 49, 64
orig: 49, 64
offset: 0, 0
index: -1
right-shoulder
rotate: false
xy: 160, 12
size: 52, 51
orig: 52, 51
offset: 0, 0
index: -1
eyes
rotate: false
xy: 214, 36
size: 34, 27
orig: 34, 27
offset: 0, 0
index: -1
right-hand
rotate: false
xy: 214, 2
size: 32, 32
orig: 32, 32
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -0,0 +1,39 @@
#include "AppDelegate.h"
#include <vector>
#include <string>
#include "ExampleScene.h"
USING_NS_CC;
using namespace std;
AppDelegate::AppDelegate() {
}
AppDelegate::~AppDelegate() {
}
bool AppDelegate::applicationDidFinishLaunching() {
CCDirector* director = CCDirector::sharedDirector();
CCEGLView* view = CCEGLView::sharedOpenGLView();
director->setOpenGLView(view);
view->setViewName("Spine Example");
view->setFrameSize(640, 480);
view->setDesignResolutionSize(640, 480, kResolutionNoBorder);
director->setDisplayStats(true);
director->runWithScene(ExampleScene::scene());
return true;
}
void AppDelegate::applicationDidEnterBackground() {
CCDirector::sharedDirector()->stopAnimation();
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
void AppDelegate::applicationWillEnterForeground() {
CCDirector::sharedDirector()->startAnimation();
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -0,0 +1,16 @@
#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,35 @@
#include "ExampleScene.h"
#include <iostream>
#include <fstream>
#include <spine-cocos2dx/spine.h>
using namespace cocos2d;
using namespace spine;
using namespace std;
CCScene* ExampleScene::scene() {
CCScene *scene = CCScene::create();
ExampleScene *layer = ExampleScene::create();
scene->addChild(layer);
return scene;
}
bool ExampleScene::init() {
if (!CCLayer::init()) return false;
ifstream atlasFile("../data/spineboy.atlas");
Atlas *atlas = new Atlas(atlasFile);
SkeletonJson json(atlas);
SkeletonData *skeletonData = json.readSkeletonDataFile("../data/spineboy-skeleton.json");
Animation *animation = json.readAnimationFile("../data/spineboy-walk.json", skeletonData);
CCSkeleton* skeletonNode = new CCSkeleton(skeletonData);
skeletonNode->state->setAnimation(animation, true);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
skeletonNode->setPosition(ccp(winSize.width / 2, 20));
addChild(skeletonNode);
return true;
}

View File

@ -0,0 +1,15 @@
#ifndef _EXAMPLESCENE_H_
#define _EXAMPLESCENE_H_
#include "cocos2d.h"
class ExampleScene : public cocos2d::CCLayer {
public:
static cocos2d::CCScene* scene();
virtual bool init();
CREATE_FUNC(ExampleScene);
};
#endif // SPINE_EXAMPLESCENE_H_

View File

@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#ifndef SPINE_ATLAS_H_
#define SPINE_ATLAS_H_
#include "cocos2d.h"
#include <spine/BaseAtlas.h>
namespace spine {
class AtlasPage: public BaseAtlasPage {
public:
~AtlasPage ();
cocos2d::CCTexture2D *texture;
cocos2d::CCTextureAtlas *atlas;
};
//
class AtlasRegion: public BaseAtlasRegion {
public:
AtlasPage *page;
};
//
class Atlas: public BaseAtlas {
public:
Atlas (std::ifstream &file);
Atlas (std::istream &input);
Atlas (const std::string &text);
Atlas (const char *begin, const char *end);
AtlasRegion* findRegion (const std::string &name);
private:
virtual BaseAtlasPage* newAtlasPage (const std::string &name);
virtual BaseAtlasRegion* newAtlasRegion (BaseAtlasPage* page);
};
} /* namespace spine */
#endif /* SPINE_ATLAS_H_ */

View File

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#ifndef SPINE_ATLASATTACHMENTLOADER_H_
#define SPINE_ATLASATTACHMENTLOADER_H_
#include <spine/BaseAttachmentLoader.h>
namespace spine {
class Atlas;
class AtlasAttachmentLoader: public BaseAttachmentLoader {
public:
Atlas *atlas;
AtlasAttachmentLoader (Atlas *atlas);
virtual Attachment* newAttachment (AttachmentType type, const std::string &name);
};
} /* namespace spine */
#endif /* SPINE_ATLASATTACHMENTLOADER_H_ */

View File

@ -0,0 +1,51 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#ifndef SPINE_CCSKELETON_H_
#define SPINE_CCSKELETON_H_
#include "base_nodes/CCNode.h"
namespace spine {
class SkeletonData;
class Skeleton;
class AnimationState;
class AnimationStateData;
class CCSkeleton: public cocos2d::CCNode {
public:
Skeleton *skeleton;
AnimationState *state;
CCSkeleton (SkeletonData *skeletonData, AnimationStateData *stateData = 0);
virtual ~CCSkeleton ();
virtual void update (float deltaTime);
virtual void draw ();
};
} /* namespace spine */
#endif /* SPINE_CCSKELETON_H_ */

View File

@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#ifndef SPINE_REGIONATTACHMENT_H_
#define SPINE_REGIONATTACHMENT_H_
#include "cocos2d.h"
#include <spine/BaseRegionAttachment.h>
namespace spine {
class Bone;
class AtlasRegion;
class RegionAttachment: public BaseRegionAttachment {
public:
cocos2d::ccV3F_C4B_T2F_Quad quad;
cocos2d::CCTextureAtlas *atlas;
RegionAttachment (AtlasRegion *region);
virtual void updateWorldVertices (Bone *bone);
virtual void draw (Slot *slot);
};
} /* namespace spine */
#endif /* SPINE_REGIONATTACHMENT_H_ */

View File

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#ifndef SPINE_SKELETON_H_
#define SPINE_SKELETON_H_
#include "cocos2d.h"
#include <spine/BaseSkeleton.h>
namespace spine {
class Skeleton: public BaseSkeleton {
private:
unsigned int quadCount;
public:
cocos2d::CCTextureAtlas *atlas; // All region attachments must use the same texture.
Skeleton (SkeletonData *skeletonData);
void addQuad (cocos2d::CCTextureAtlas *atlas, cocos2d::ccV3F_C4B_T2F_Quad &quad);
virtual void draw ();
};
} /* namespace spine */
#endif /* SPINE_SKELETON_H_ */

View File

@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#ifndef SPINE_SKELETONJSON_H_
#define SPINE_SKELETONJSON_H_
#include <spine/BaseSkeletonJson.h>
namespace spine {
class Atlas;
class SkeletonJson: public BaseSkeletonJson {
public:
SkeletonJson (Atlas *atlas);
/** The SkeletonJson owns the attachmentLoader. */
SkeletonJson (BaseAttachmentLoader *attachmentLoader);
};
} /* namespace spine */
#endif /* SPINE_SKELETONJSON_H_ */

View File

@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#ifndef SPINE_SPINE_H_
#define SPINE_SPINE_H_
#include <spine/SkeletonData.h>
#include <spine/BoneData.h>
#include <spine/SlotData.h>
#include <spine/Skin.h>
#include <spine/Attachment.h>
#include <spine/Animation.h>
#include <spine/AnimationStateData.h>
#include <spine/AnimationState.h>
#include <spine/Slot.h>
#include <spine/Bone.h>
#include <spine-cocos2dx/RegionAttachment.h>
#include <spine-cocos2dx/Atlas.h>
#include <spine-cocos2dx/AtlasAttachmentLoader.h>
#include <spine-cocos2dx/SkeletonJson.h>
#include <spine-cocos2dx/Skeleton.h>
#include <spine-cocos2dx/CCSkeleton.h>
#endif /* SF_SPINE_H_ */

View File

@ -0,0 +1,11 @@
#include "main.h"
#include "../example/AppDelegate.h"
USING_NS_CC;
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
AppDelegate app;
return CCApplication::sharedApplication()->run();
}

View File

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

View File

@ -0,0 +1,201 @@
<?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>{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}</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)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\include;$(ProjectDir)..\..\..\spine-cpp\include;$(ProjectDir)..\..\..\spine-cpp\src;%(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>
</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>
</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="..\..\..\spine-cpp\include\json\autolink.h" />
<ClInclude Include="..\..\..\spine-cpp\include\json\config.h" />
<ClInclude Include="..\..\..\spine-cpp\include\json\features.h" />
<ClInclude Include="..\..\..\spine-cpp\include\json\forwards.h" />
<ClInclude Include="..\..\..\spine-cpp\include\json\json.h" />
<ClInclude Include="..\..\..\spine-cpp\include\json\reader.h" />
<ClInclude Include="..\..\..\spine-cpp\include\json\value.h" />
<ClInclude Include="..\..\..\spine-cpp\include\json\writer.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\Animation.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\AnimationState.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\AnimationStateData.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\Attachment.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseAtlas.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseAttachmentLoader.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseRegionAttachment.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseSkeleton.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseSkeletonJson.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\Bone.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\BoneData.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\SkeletonData.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\Skin.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\Slot.h" />
<ClInclude Include="..\..\..\spine-cpp\include\spine\SlotData.h" />
<ClInclude Include="..\..\..\spine-cpp\src\json\json_batchallocator.h" />
<ClInclude Include="..\example\AppDelegate.h" />
<ClInclude Include="..\example\ExampleScene.h" />
<ClInclude Include="..\include\spine-cocos2dx\Atlas.h" />
<ClInclude Include="..\include\spine-cocos2dx\AtlasAttachmentLoader.h" />
<ClInclude Include="..\include\spine-cocos2dx\CCSkeleton.h" />
<ClInclude Include="..\include\spine-cocos2dx\RegionAttachment.h" />
<ClInclude Include="..\include\spine-cocos2dx\Skeleton.h" />
<ClInclude Include="..\include\spine-cocos2dx\SkeletonJson.h" />
<ClInclude Include="..\include\spine-cocos2dx\spine.h" />
<ClInclude Include="main.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\spine-cpp\src\json\json_reader.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\json\json_value.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\json\json_writer.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\Animation.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\AnimationState.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\AnimationStateData.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\BaseAtlas.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\BaseRegionAttachment.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\BaseSkeleton.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\BaseSkeletonJson.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\Bone.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\BoneData.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\SkeletonData.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\Skin.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\Slot.cpp" />
<ClCompile Include="..\..\..\spine-cpp\src\spine\SlotData.cpp" />
<ClCompile Include="..\example\AppDelegate.cpp" />
<ClCompile Include="..\example\ExampleScene.cpp" />
<ClCompile Include="..\src\spine-cocos2dx\Atlas.cpp" />
<ClCompile Include="..\src\spine-cocos2dx\AtlasAttachmentLoader.cpp" />
<ClCompile Include="..\src\spine-cocos2dx\CCSkeleton.cpp" />
<ClCompile Include="..\src\spine-cocos2dx\RegionAttachment.cpp" />
<ClCompile Include="..\src\spine-cocos2dx\Skeleton.cpp" />
<ClCompile Include="..\src\spine-cocos2dx\SkeletonJson.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\cocos2dx\proj.win32\cocos2d.vcxproj">
<Project>{98a51ba8-fc3a-415b-ac8f-8c7bd464e93e}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\spine-cpp\src\json\json_internalarray.inl" />
<None Include="..\..\..\spine-cpp\src\json\json_internalmap.inl" />
<None Include="..\..\..\spine-cpp\src\json\json_valueiterator.inl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,224 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="includes">
<UniqueIdentifier>{1b06b916-430b-4dc1-b260-c280a58e0d17}</UniqueIdentifier>
</Filter>
<Filter Include="includes\spine">
<UniqueIdentifier>{e7aa2d8d-104e-4c2c-a383-2709ccc2ebf5}</UniqueIdentifier>
</Filter>
<Filter Include="includes\json">
<UniqueIdentifier>{c5903be8-3874-4598-afb8-502a53a1bbac}</UniqueIdentifier>
</Filter>
<Filter Include="includes\spine-cocos2dx">
<UniqueIdentifier>{29fcfe1f-7289-4597-a8fc-82ab7431ba7d}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{79f098e3-3dd1-47bb-a0a7-1a861d7da7ee}</UniqueIdentifier>
</Filter>
<Filter Include="src\spine">
<UniqueIdentifier>{036946b8-8d3d-448b-b494-10ee7bbdf1ea}</UniqueIdentifier>
</Filter>
<Filter Include="src\json">
<UniqueIdentifier>{44d6db46-e6b8-40ea-b950-8d75550614ce}</UniqueIdentifier>
</Filter>
<Filter Include="src\spine-cocos2dx">
<UniqueIdentifier>{373e4aa7-5d88-40c4-877d-431185461bfb}</UniqueIdentifier>
</Filter>
<Filter Include="example">
<UniqueIdentifier>{ef769de4-53ac-449d-92e6-e67ec8d7414e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\spine-cocos2dx\Atlas.h">
<Filter>includes\spine-cocos2dx</Filter>
</ClInclude>
<ClInclude Include="..\include\spine-cocos2dx\AtlasAttachmentLoader.h">
<Filter>includes\spine-cocos2dx</Filter>
</ClInclude>
<ClInclude Include="..\include\spine-cocos2dx\RegionAttachment.h">
<Filter>includes\spine-cocos2dx</Filter>
</ClInclude>
<ClInclude Include="..\include\spine-cocos2dx\Skeleton.h">
<Filter>includes\spine-cocos2dx</Filter>
</ClInclude>
<ClInclude Include="..\include\spine-cocos2dx\SkeletonJson.h">
<Filter>includes\spine-cocos2dx</Filter>
</ClInclude>
<ClInclude Include="..\include\spine-cocos2dx\spine.h">
<Filter>includes\spine-cocos2dx</Filter>
</ClInclude>
<ClInclude Include="..\example\AppDelegate.h">
<Filter>example</Filter>
</ClInclude>
<ClInclude Include="..\example\ExampleScene.h">
<Filter>example</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>example</Filter>
</ClInclude>
<ClInclude Include="..\include\spine-cocos2dx\CCSkeleton.h">
<Filter>includes\spine-cocos2dx</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\json\value.h">
<Filter>includes\json</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\json\writer.h">
<Filter>includes\json</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\json\autolink.h">
<Filter>includes\json</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\json\config.h">
<Filter>includes\json</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\json\features.h">
<Filter>includes\json</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\json\forwards.h">
<Filter>includes\json</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\json\json.h">
<Filter>includes\json</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\json\reader.h">
<Filter>includes\json</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseAtlas.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseAttachmentLoader.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseRegionAttachment.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseSkeleton.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\BaseSkeletonJson.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\Bone.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\BoneData.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\SkeletonData.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\Skin.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\Slot.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\SlotData.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\Animation.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\AnimationState.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\AnimationStateData.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\include\spine\Attachment.h">
<Filter>includes\spine</Filter>
</ClInclude>
<ClInclude Include="..\..\..\spine-cpp\src\json\json_batchallocator.h">
<Filter>src\json</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\spine-cocos2dx\Atlas.cpp">
<Filter>src\spine-cocos2dx</Filter>
</ClCompile>
<ClCompile Include="..\src\spine-cocos2dx\AtlasAttachmentLoader.cpp">
<Filter>src\spine-cocos2dx</Filter>
</ClCompile>
<ClCompile Include="..\src\spine-cocos2dx\RegionAttachment.cpp">
<Filter>src\spine-cocos2dx</Filter>
</ClCompile>
<ClCompile Include="..\src\spine-cocos2dx\Skeleton.cpp">
<Filter>src\spine-cocos2dx</Filter>
</ClCompile>
<ClCompile Include="..\src\spine-cocos2dx\SkeletonJson.cpp">
<Filter>src\spine-cocos2dx</Filter>
</ClCompile>
<ClCompile Include="..\example\AppDelegate.cpp">
<Filter>example</Filter>
</ClCompile>
<ClCompile Include="..\example\ExampleScene.cpp">
<Filter>example</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>example</Filter>
</ClCompile>
<ClCompile Include="..\src\spine-cocos2dx\CCSkeleton.cpp">
<Filter>src\spine-cocos2dx</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\json\json_reader.cpp">
<Filter>src\json</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\json\json_value.cpp">
<Filter>src\json</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\json\json_writer.cpp">
<Filter>src\json</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\Animation.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\AnimationState.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\AnimationStateData.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\BaseAtlas.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\BaseRegionAttachment.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\BaseSkeleton.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\BaseSkeletonJson.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\Bone.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\BoneData.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\SkeletonData.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\Skin.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\Slot.cpp">
<Filter>src\spine</Filter>
</ClCompile>
<ClCompile Include="..\..\..\spine-cpp\src\spine\SlotData.cpp">
<Filter>src\spine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\spine-cpp\src\json\json_internalarray.inl">
<Filter>src\json</Filter>
</None>
<None Include="..\..\..\spine-cpp\src\json\json_internalmap.inl">
<Filter>src\json</Filter>
</None>
<None Include="..\..\..\spine-cpp\src\json\json_valueiterator.inl">
<Filter>src\json</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,73 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include <spine-cocos2dx/Atlas.h>
USING_NS_CC;
namespace spine {
AtlasPage::~AtlasPage () {
CC_SAFE_RELEASE_NULL(texture);
CC_SAFE_RELEASE_NULL(atlas);
}
//
Atlas::Atlas (std::ifstream &file) {
load(file);
}
Atlas::Atlas (std::istream &input) {
load(input);
}
Atlas::Atlas (const std::string &text) {
load(text);
}
Atlas::Atlas (const char *begin, const char *end) {
load(begin, end);
}
BaseAtlasPage* Atlas::newAtlasPage (const std::string &name) {
AtlasPage *page = new AtlasPage();
page->texture = CCTextureCache::sharedTextureCache()->addImage(name.c_str());
page->atlas = CCTextureAtlas::createWithTexture(page->texture, 4);
page->atlas->retain();
return page;
}
BaseAtlasRegion* Atlas::newAtlasRegion (BaseAtlasPage* page) {
AtlasRegion *region = new AtlasRegion();
region->page = reinterpret_cast<AtlasPage*>(page);
return region;
}
AtlasRegion* Atlas::findRegion (const std::string &name) {
return reinterpret_cast<AtlasRegion*>(BaseAtlas::findRegion(name));
}
} /* namespace spine */

View File

@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include <stdexcept>
#include <spine-cocos2dx/AtlasAttachmentLoader.h>
#include <spine-cocos2dx/Atlas.h>
#include <spine-cocos2dx/RegionAttachment.h>
namespace spine {
AtlasAttachmentLoader::AtlasAttachmentLoader (Atlas *atlas) :
atlas(atlas) {
}
Attachment* AtlasAttachmentLoader::newAttachment (AttachmentType type, const std::string &name) {
switch (type) {
case region: {
AtlasRegion *region = atlas->findRegion(name);
if (!region) throw std::runtime_error("Atlas region not found: " + name);
return new RegionAttachment(region);
}
default:
throw std::runtime_error("Unknown attachment type: " + type);
}
}
} /* namespace spine */

View File

@ -0,0 +1,61 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include <spine-cocos2dx/CCSkeleton.h>
#include <stdexcept>
#include <spine/SkeletonData.h>
#include <spine-cocos2dx/Skeleton.h>
#include <spine/AnimationState.h>
#include <spine/AnimationStateData.h>
using namespace spine;
USING_NS_CC;
CCSkeleton::CCSkeleton (SkeletonData *skeletonData, AnimationStateData *stateData) {
if (!skeletonData) throw std::invalid_argument("skeletonData cannot be null.");
skeleton = new Skeleton(skeletonData);
state = new AnimationState(stateData);
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));
scheduleUpdate();
}
CCSkeleton::~CCSkeleton () {
delete skeleton;
delete state;
}
void CCSkeleton::update (float deltaTime) {
skeleton->update(deltaTime);
state->update(deltaTime);
state->apply(skeleton);
skeleton->updateWorldTransform();
}
void CCSkeleton::draw () {
CC_NODE_DRAW_SETUP();
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
skeleton->draw();
}

View File

@ -0,0 +1,111 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include <iostream>
#include <spine-cocos2dx/RegionAttachment.h>
#include <spine-cocos2dx/Atlas.h>
#include <spine-cocos2dx/Skeleton.h>
#include <spine/Bone.h>
#include <spine/Slot.h>
USING_NS_CC;
namespace spine {
RegionAttachment::RegionAttachment (AtlasRegion *region) {
atlas = region->page->atlas;
const CCSize &size = region->page->texture->getContentSizeInPixels();
float u = region->x / size.width;
float u2 = (region->x + region->width) / size.width;
float v = region->y / size.height;
float v2 = (region->y + region->height) / size.height;
if (region->rotate) {
quad.tl.texCoords.u = u;
quad.tl.texCoords.v = v2;
quad.tr.texCoords.u = u;
quad.tr.texCoords.v = v;
quad.br.texCoords.u = u2;
quad.br.texCoords.v = v;
quad.bl.texCoords.u = u2;
quad.bl.texCoords.v = v2;
} else {
quad.bl.texCoords.u = u;
quad.bl.texCoords.v = v2;
quad.tl.texCoords.u = u;
quad.tl.texCoords.v = v;
quad.tr.texCoords.u = u2;
quad.tr.texCoords.v = v;
quad.br.texCoords.u = u2;
quad.br.texCoords.v = v2;
}
quad.bl.vertices.z = 0;
quad.tl.vertices.z = 0;
quad.tr.vertices.z = 0;
quad.br.vertices.z = 0;
}
void RegionAttachment::draw (Slot *slot) {
Skeleton* skeleton = (Skeleton*)slot->skeleton;
GLubyte r = skeleton->r * slot->r * 255;
GLubyte g = skeleton->g * slot->g * 255;
GLubyte b = skeleton->b * slot->b * 255;
GLubyte a = skeleton->a * slot->a * 255;
quad.bl.colors.r = r;
quad.bl.colors.g = g;
quad.bl.colors.b = b;
quad.bl.colors.a = a;
quad.tl.colors.r = r;
quad.tl.colors.g = g;
quad.tl.colors.b = b;
quad.tl.colors.a = a;
quad.tr.colors.r = r;
quad.tr.colors.g = g;
quad.tr.colors.b = b;
quad.tr.colors.a = a;
quad.br.colors.r = r;
quad.br.colors.g = g;
quad.br.colors.b = b;
quad.br.colors.a = a;
updateWorldVertices(slot->bone);
// cocos2dx doesn't handle batching for us, so we'll just force a single texture per skeleton.
skeleton->addQuad(atlas, quad);
}
void RegionAttachment::updateWorldVertices (spine::Bone *bone) {
quad.bl.vertices.x = offset[0] * bone->m00 + offset[1] * bone->m01 + bone->worldX;
quad.bl.vertices.y = offset[0] * bone->m10 + offset[1] * bone->m11 + bone->worldY;
quad.tl.vertices.x = offset[2] * bone->m00 + offset[3] * bone->m01 + bone->worldX;
quad.tl.vertices.y = offset[2] * bone->m10 + offset[3] * bone->m11 + bone->worldY;
quad.tr.vertices.x = offset[4] * bone->m00 + offset[5] * bone->m01 + bone->worldX;
quad.tr.vertices.y = offset[4] * bone->m10 + offset[5] * bone->m11 + bone->worldY;
quad.br.vertices.x = offset[6] * bone->m00 + offset[7] * bone->m01 + bone->worldX;
quad.br.vertices.y = offset[6] * bone->m10 + offset[7] * bone->m11 + bone->worldY;
}
} /* namespace spine */

View File

@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include <iostream>
#include <spine-cocos2dx/Skeleton.h>
#include <spine/SkeletonData.h>
#include <spine/Slot.h>
#include <spine/Attachment.h>
USING_NS_CC;
namespace spine {
Skeleton::Skeleton (SkeletonData *skeletonData) :
BaseSkeleton(skeletonData),
quadCount(0),
atlas(0) {
}
void Skeleton::addQuad (cocos2d::CCTextureAtlas *atlas, cocos2d::ccV3F_C4B_T2F_Quad &quad) {
this->atlas = atlas;
if (atlas->getCapacity() <= quadCount) {
if (!atlas->resizeCapacity(atlas->getCapacity() * 2)) return;
}
atlas->updateQuad(&quad, quadCount++);
}
void Skeleton::draw () {
quadCount = 0;
for (int i = 0, n = slots.size(); i < n; i++)
if (slots[i]->attachment) slots[i]->attachment->draw(slots[i]);
if (atlas) atlas->drawNumberOfQuads(quadCount);
}
} /* namespace spine */

View File

@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include <spine-cocos2dx/SkeletonJson.h>
#include <spine-cocos2dx/AtlasAttachmentLoader.h>
namespace spine {
SkeletonJson::SkeletonJson (BaseAttachmentLoader *attachmentLoader) :
BaseSkeletonJson(attachmentLoader) {
}
SkeletonJson::SkeletonJson (Atlas *atlas) :
BaseSkeletonJson(new AtlasAttachmentLoader(atlas)) {
}
} /* namespace spine */