Thanks Nathan, I makes sense now 
Cheers
Thanks Nathan, I makes sense now 
Cheers
Didnât managed to run this for android yet, any android project examples available ?
Especially regarding the makefile, adding reference to headers is trivial:
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
../../spine-runtimes/spine-cpp/include \
../../spine-runtimes/spine-cocos2dx/include
Having difficulties to reference the source files though.
Using wildcard doesnât seem to find any sources (cant disregard syntax or path issue here)
#GAME
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
(...)
#JSON
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH) ../../spine-runtimes/spine-cpp/src/json/*.cpp)
Adding every single source file (exhaustingâŚ) leads to compile error.
# GAME
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
(...)
# JSON
LOCAL_SRC_FILES += ../../../spine-runtimes/spine-cpp/src/json/json_reader.cpp \
../../../spine-runtimes/spine-cpp/src/json/json_value.cpp \
../../../spine-runtimes/spine-cpp/src/json/json_writer.cpp
jni/../../../spine-runtimes/spine-cpp/src/json/json_reader.cpp: In function 'std::istream& Json::operator>>(std::istream&, Json::Value&)':
jni/../../../spine-runtimes/spine-cpp/src/json/json_reader.cpp:880: error: exception handling disabled, use -fexceptions to enable
We are running the example and sometime we have problems with alpha transparency.
In my Pc (Seven64, Radeon 6850) the alpha transparency is always gone (look the right picture at the eyes). And the fade rutineâŚis not working as intent (left).
In another PC (WinXP) sometime runs nice, sometime doesnât workâŚany idea?
PS: skeletonNode->boundingBox().width and height return always 0. Bug?
Iâve been working on a C API, which I just finished:
https://github.com/EsotericSoftware/spine-runtimes/tree/master/spine-c
I donât think it makes sense to maintain both a C++ and C API, so I will get rid of spine-cpp and convert spine-cocos2dx to use spine-c. Things are better in spine-c too, the attachment loading is cleaner, the JSON parsing is much better. spine-c is also easier to extend, just implement a couple functions. Iâve converted spine-sfml to use spine-c instead of spine-cpp and the whole SFML runtime is only 136 LOC!
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-sfml/src/spine/spine-sfml.cpp
`Luis Mendes, I havenât had a chance to build it for Android. Use âls -1 > files.txtâ to make a list of files to paste into the build. spine-c is plain C so should be easier to build. Of course it doesnât use exceptions so that wonât be a problem anymore. 
`Williams Piazza, your alpha transparency looks like a problem with premultiplied alpha. The left image looks correct, Spine draws many images on top of each other so if you fade them all this is how they will look. You can render to an FBO and then draw that with transparency to avoid the issue. Setting the CCSkeletonâs bounding box isnât implemented, I didnât notice it was needed. It can be computed by taking the min/max of each vertex for each region attachment. sometime runs nice, sometime doesnât work
https://code.google.com/p/libgdx/wiki/GettingHelp#Problem_Statement
@Williams Piazza, your alpha transparency looks like a problem with premultiplied alpha. The left image looks correct, Spine draws many images on top of each other so if you fade them all this is how they will look. You can render to an FBO and then draw that with transparency to avoid the issue. Setting the CCSkeletonâs bounding box isnât implemented, I didnât notice it was needed. It can be computed by taking the min/max of each vertex for each region attachment. sometime runs nice, sometime doesnât work
https://code.google.com/p/libgdx/wiki/GettingHelp\#Problem\_Statement
bounding box is not needed, just used it to test and reported. Maybe a LOG call with âBounding not implementedâ inside the function is enought.
For the âpremultiplied alphaâ iâve just run the example and that was how looks. Not as intended i suppose âŚ
Nice for u to remove the c++ stuff, less work for u = faster release for us ![]()
The alpha problem is fixed.
Iâve finished rewriting the cocos2dx runtime. It now uses spine-c, the generic C runtime. The entire cocos2dx specific code is ~250 lines in a single file:
The API to make use of it looks like this:
Hope you guys like it! 
Nathan Sweet wrote:
The alpha problem is fixed.
>
Iâve finished rewriting the cocos2dx runtime. It now uses spine-c, the generic C runtime. The entire cocos2dx specific code is ~250 lines in a single file:
>
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-cocos2dx/src/spine/spine-cocos2dx.cpp
>
The API to make use of it looks like this:
>
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-cocos2dx/example/Classes/ExampleLayer.cpp\#L18
>
Hope you guys like it!
Like it very much! Thanks so much!
Nathan Sweet wrote:
The alpha problem is fixed.
>
Iâve finished rewriting the cocos2dx runtime. It now uses spine-c, the generic C runtime. The entire cocos2dx specific code is ~250 lines in a single file:
>
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-cocos2dx/src/spine/spine-cocos2dx.cpp
>
The API to make use of it looks like this:
>
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-cocos2dx/example/Classes/ExampleLayer.cpp\#L18
>
Hope you guys like it!
Tnks for the new example, now the mix is easier to learn ![]()
However now the skeletonNode->timeScale is set to 0 by default and i need to put at 1.0f to run somethingâŚ
Tryed to compile my code and was all stoned ![]()
Nathan Sweet wrote:
The alpha problem is fixed.
>
Iâve finished rewriting the cocos2dx runtime. It now uses spine-c, the generic C runtime. The entire cocos2dx specific code is ~250 lines in a single file:
>
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-cocos2dx/src/spine/spine-cocos2dx.cpp
>
The API to make use of it looks like this:
>
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-cocos2dx/example/Classes/ExampleLayer.cpp\#L18
>
Hope you guys like it!
Lovely Nathan ! Good job ![]()
Oops! timeScale is fixed. 
@Nathan Sweet
How can i detect the animation is done?
Have any callback method when selected animation is done?
Hi, Iâve created an android project for the spine-cocos2dx example.
Just unzip it under âspine-runtimes\spine-cocos2dx\example\proj.androidâ modify build_native.sh to point to your NDK path and try to compile the library.
Project was created with latest cocos2dx-2.1.2 project creator, in which eclipse project contains c++ build settings and can also be compiled from there (add NDK to PATH first).
Tried it in my SGS3 and worked fine, please try it out and fix it if needed 
`Wei-Sung Yeh, sorry I didnât see your post sooner. You know an animation is done when the time is >= the animation duration. If you are using AnimationState, the time is state->time. Eg, for CCSkeleton itâs âskeleton->state->time >= skeleton->state->animation->durationâ.
`Luis Mendes, nice, thanks! Iâve added your project to spine-cocos2dx.
Havenât had a chance to test it though.
Hello!
@Nathan Sweet: Spine is a great tool and weâll be using it for sure :). I understand that the runtimes are still under development and that you are working on that. I was testing the runtime under Linux and mostly it works great, but there are a few issues:
The Goblins Example doesnât display any skin ( even if I set the skins to goblin or goblingirl), it only displays the knife and spear as it is the default if I understand correctly.
I have checked for memory leaks with Valgrind and it reports:
Mismatched free() / delete / delete [] in spine::CCSkeleton::create(char const*, char const*, float) in Classes/spine-cocos2dx.cpp:86
Mismatched free() / delete / delete [] in spine::CCSkeleton::create(char const*, char const*, float) in Classes/spine-cocos2dx.cpp:90
32 bytes in 1 blocks are definitely lost in loss record 39 of 118 in spine::CCSkeleton::create(char const*, char const*, float) in Classes/spine-cocos2dx.cpp:88
22,122 (72 direct, 22,050 indirect) bytes in 1 blocks are definitely lost in loss record 118 of 118 in spine::CCSkeleton::create(char const*, char const*, float) in Classes/spine-cocos2dx.cpp:90
Not really an issue, but more of a feature lack, it would be nice to flip (X or Y) the skeleton (as I said I understand that itâs still under development :), and will be patient).
I also have a suggestion ( it includes more the cocos2dx community). To keep all the projects well organised it would make sense to make a static library (like chipmunk) of the spine-c runtime, in the âexternalâ folder (where all the others are). I have done just that for Linux, will make it for Blackberry soon, but with Android I have a few issues.
With Android Iâm having trouble. The example from Luis Mendes, the project builds but there is no bin folder and no apk (no binary). And the static lib approach gives me reference errors.
Sorry for the long post, and I hope I was clear and not confusing :).
@Stanko KrstiÄ, thanks for your feedback! 
Youâll need to call setSlotsToBindPose() after calling setSkin. See comments on setSkin, but it only attaches images from the new skin if an attachment was there from the old skin. Since you are setting the skin for the first time, there is no old skin so setSkin doesnât attach anything. setSlotsToBindPose sets the image for each slot to how they are in the bind pose.
Maybe Iâm blind, but I donât see why it complains?
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-cocos2dx/src/spine/spine-cocos2dx.cpp#L82
Use skeletonNode~~>skeleton~~>flipX/Y = true. You can also setScaleX(â1) on the skeleton node.
Including static libraries would be nice, but is a lot of effort for me to do for each change. Better people just grab the source and compile themselves, which seems to be the cocos2d way.
Not sure on Android, sorry! A native Android build can be a huge pain. Anything Android can be a huge pain!
@Nathan Sweet: Thank you for your reply :). Next time Iâll read the documentation first and examine the code :). The memory thing doesnât make sense to me either (I will check in to that). And the Android thing was meant for the community. Iâll play a little with that and hope to manage to get it working. You just focus on the runtimes ;). And have a nice day 
No worries, itâs tricky (especially setSkin) and there isnât much (ok, any) documentation for the runtime yet. 
It would be really fun to see the some ragdoll effect with box2d physics, Is possible to manipulate spine bones when the animation is running?
Good job !
For Box2D youâd use the skeleton and animation to position Box2D bodys. For rag doll youâd stop positioning them and let the physics take over. Here is an example of the first part (in Java):
Yes, you can manipulate bones at runtime and combine that with animations:
Stanko KrstiÄ wrote:
@Nathan Sweet: Thank you for your reply :). Next time Iâll read the documentation first and examine the code :). The memory thing doesnât make sense to me either (I will check in to that). And the Android thing was meant for the community. Iâll play a little with that and hope to manage to get it working. You just focus on the runtimes ;). And have a nice day
Hi Stanko,
I provided the initial android project example, not sure if there were additional changes afterwards, I think not though.
Am not an android or programming expert
so I invite anyone in the community to improve/correct the example.
The process was simple though:
Regarding the issues you faced, I tried now with project from repository (to exclude any diff in my local files):
Considering the cocos2dx android project (org.cocos2dx.lib) is already open in Eclipse
Build was successful, no APK generated though. Not sure if APK should generated at this step, probably just the library.
However if running the project in emulator or device APK is generated.
My setup is Windows 7, cygwin + NDK R8E.
Cheers,
Luis