The spine-cocos2dx runtime provides functionality to load, manipulate and render Spine skeletal animation data using cocos2d-x. spine-cocos2dx is based on spine-c.
This Spine Runtime may only be used for personal or internal use, typically to evaluate Spine before purchasing. If you would like to incorporate a Spine Runtime into your applications, distribute software containing a Spine Runtime, or modify a Spine Runtime, then you will need a valid Spine license. Please see the Spine Runtimes Software License for detailed information.
The Spine Runtimes are developed with the intent to be used with data exported from Spine. By purchasing Spine, Section 2
of the Spine Software License grants the right to create and distribute derivative works of the Spine Runtimes.
spine-cocos2dx works with data exported from Spine 3.5.xx.
spine-cocos2dx supports all Spine features.
spine-cocos2dx does not yet support loading the binary format.
The setup for cocos2d-x differs from most other Spine Runtimes because the cocos2d-x distribution includes a copy of the Spine Runtime files. This is not ideal because these files may be old and fail to work with the latest Spine editor. Also it means if cocos2d-x is updated, you may get newer Spine Runtime files which can break your application if you are not using the latest Spine editor. For these reasons, we have requested cocos2d-x to cease distributing the Spine Runtime files, but they continue to do so. The following instructions allow you to use the official Spine cocos2d-x runtime with your cocos2d-x project.
- Create a new cocos2d-x project. See the cocos2d-x documentation
- Delete the folder
cocos2d/cocos/editor-support/spine
. This will remove the outdated Spine cocos2d-x runtime shipped by cocos2d-x. - Open your project in your IDE of choice, then open the cocos2d_libs sub project and delete the
editor-support/spine
group. This will remove the outdated Spine cocos2d-x runtime shipped by cocos2d-x from your build. - Download the Spine Runtimes source using git (
git clone https://github.com/esotericsoftware/spine-runtimes
) or download it as a zip - Add the sources from
spine-c/spine-c/src/spine
andspine-cocos2dx/src/spine
to your project - Add the folders
spine-c/spine-c/include
andspine-cocos2dx/src
to your header search path. Note that includes are specified as#inclue <spine/file.h>
, so thespine
directory cannot be omitted when copying the source files.
The Spine cocos2d-x example works on Windows and Mac OS X.
- Install Visual Studio 2015 Community
- Install CMake via the Windows installer package.
- Download the Spine Runtimes repository using git (
git clone https://github.com/esotericsoftware/spine-runtimes
) or download it as a zip - Run CMake GUI from the start menu
- Click
Browse Source
and select the directoryspine-runtimes
- Click
Browse Build
and select thespine-runtimes/spine-cocos2dx/build
directory. You can create thebuild
folder directly in the file dialog viaNew Folder
. - Click
Configure
. This will download the cocos2d-x dependency and wire it up with the example source code inspine-runtimes/spine-cocos2dx/example
. The download is 400mb, so get yourself a cup of tea. - Open the
spine-runtimes/spine-cocos2dx/example/proj.win32/spine-cocos2d-x.sln
file in Visual Studio 2015. Visual Studio may ask you to install the Windows XP/7 SDK, which you should install. - Expand the cocos2d_libs sub project and delete the
editor-support/spine
group. This will remove the outdated Spine cocos2d-x runtime shipped by cocos2d-x from your build. - Expand
References
of the cocos2d_libs sub project, and remove the entry forlibSpine
, which should be marked with an error. - Right click the
spine-cocos2d-x
project in the solution explorer and selectSet as Startup Project
from the context menu - Click
Local Windows Debugger
to run the example
- Install Xcode
- Install Homebrew
- Open a terminal and install CMake via
brew install cmake
- Download the Spine Runtimes repository using git (
git clone https://github.com/esotericsoftware/spine-runtimes
) or download it as a zip - Open a terminal, and
cd
into thespine-runtimes/spine-cocos2dx
folder - Type
mkdir build && cd build && cmake ../..
. This will download the cocos2d-x dependency and wire it up with the example source code inspine-runtimes/spine-cocos2dx/example
. The download is 400mb, so get yourself a cup of tea. - Open the Xcode project in
spine-runtimes/spine-cocos2dx/example/proj.ios_mac
- Expand the
cocos2d_libs.xcodeproj
sub project, delete the groupeditor-support/spine
. This will remove the outdated Spine cocos2d-x runtime shipped by cocos2d-x. - Click the
Run
button or typeCMD+R
to run the example
- Install the prerequisits for cocos2d-x Android development
- Install Homebrew
- Open a terminal and install CMake via
brew install cmake
- Download the Spine Runtimes repository using git (
git clone https://github.com/esotericsoftware/spine-runtimes
) or download it as a zip - Open a terminal, and
cd
into thespine-runtimes/spine-cocos2dx
folder - Type
mkdir build && cd build && cmake ../..
. This will download the cocos2d-x dependency and wire it up with the example source code inspine-runtimes/spine-cocos2dx/example
. The download is 400mb, so get yourself a cup of tea. - Delete
spine-runtimes/spine-cocos2dx/example/cocos2d/cocos/editor-support/spine
- Open
spine-runtimes/spine-cocos2dx/example/cocos2d/cocos/Android.mk
and remove the linesLOCAL_STATIC_LIBRARIES += spine_static
and `$(call import-module,editor-support/spine) - Switch to
spine-runtimes/spine-cocos2dx/example/proj.android/jni
and executecocos compile -p android -m debug --ndk-mode debug
to compile the example for Android - In the same directory, execute
cocos run -p android -m debug
to deploy to the device - For debugging, run
ndk-debug
in theproj.android/jni
folder. This will attach to the running app via GDB.
- Images are premultiplied by cocos2d-x, so the Spine atlas images should not use premultiplied alpha.