• Editor
  • [Cocos2d-x] Difficulties implementing the cocos2d-x runtime

I was able to purchase Spine a few weeks ago and I really enjoy the software. It's pretty easy to use and I can see that it will save me quite a lot of time in the future.

So far, I have made a few animations and I'd like to see how they work in-game; however, I'm having hard time learning how to add the runtime to one of my created x-code projects. I'm using cocos2d-x and I am fairly new to it. I've been trying to get this work for about a few hours or so with no luck.

A step-by-step tutorial on this would be appreciated greatly as I am a beginner, but really any help would be welcome.

Related Discussions
...
  • Đã chỉnh sửa

I'm writing some docs for using runtimes now. Getting married today so I won't have time to finish it for a couple days, but you can see a rough draft of what I have so far:
http://pastebin.com/7UDRxawx
For now, I suggest getting the example that comes with spine-cocs2dx to work, then replacing the skeleton and atlas with your own. By that time you should be able to get it into your project. For more advanced usage, try searching the forum, a number of questions have been answered.

Wow! Congratulation on your wedding!

Nate đã viết

I'm writing some docs for using runtimes now. Getting married today so I won't have time to finish it for a couple days, but you can see a rough draft of what I have so far:
http://pastebin.com/7UDRxawx
For now, I suggest getting the example that comes with spine-cocs2dx to work, then replacing the skeleton and atlas with your own. By that time you should be able to get it into your project. For more advanced usage, try searching the forum, a number of questions have been answered.

Happy Wedding!

Nate đã viết

I'm writing some docs for using runtimes now. Getting married today so I won't have time to finish it for a couple days, but you can see a rough draft of what I have so far:
http://pastebin.com/7UDRxawx
For now, I suggest getting the example that comes with spine-cocs2dx to work, then replacing the skeleton and atlas with your own. By that time you should be able to get it into your project. For more advanced usage, try searching the forum, a number of questions have been answered.

Thanks Nate. Congratulations on being married!

I was having trouble with actually getting the example from github to work. I noticed that there was a place to put the cocos2d-x files in, but I wasn't quite sure which files to place in. I had assumed that the same files for cocos2d-x folder ( found under the libs folder for a new cocos2-dx project) would be placed in there, but when I put the files in, it still wouldn't compile correctly. (It stated that the app delegate required cocos2d.h) I also tried adding the folder into x-code, but the error remained. I'm pretty new to x-code and cocos2d-x and so I'm pretty sure that I'm doing something wrong.

No, need to get back to me immediately, I completely understand. On a side-note, I wanted to thank you for making a great product, not only does it streamline my art process, but it's also very intuitive and easy to learn.

  • Đã chỉnh sửa

Hi Epenetus,

I've got Spine working for Cocos2d-x, I hope I can help out here.

I haven't bothered getting the example running yet, so I'll go through my steps now.

Open up the project, missing "cocos2d.h"

  • take the cocos2d-x/cocos2dx folder contents from my git clone of cocos2d-x project, copy into spine-runtimes/spine-cocos2dx/cocos2dx folder

Get data from file(spineboy.atlas) failed!
I found that the setSearchPaths command was using the 'ipad' folder, which doesn't exist. I've made a change to AppMacros.h and submitted a pull request. Change AppMacros.h:64-67 to look like this:

static Resource smallResource = {cocos2d::CCSizeMake(480, 320), "iphone"};
static Resource mediumResource = {cocos2d::CCSizeMake(960, 640), "iphone-retina"};
static Resource largeResource = {cocos2d::CCSizeMake(1024, 768), "iphone-retina"};
static Resource extralargeResource = {cocos2d::CCSizeMake(2048, 1536), "iphone-retina"};

Then it ran.

I should note that when I built Spine into my existing project, I created a 'spine' folder in my project's libs directory, then put the contents of both spine-runtimes/spine-cocos2dx/src/spine and spine-runtimes/spine-c/src/spine into it. Maybe not the cleanest, but it works.

I took everything from spine-c and spine-cocos2dx and dumped them into the same folder for my project. It's maybe not the best as far as updating the runtimes go in the future but it's the easiest way for me without maintaining a bunch of different folders.

@boldbigflank & spudworks I haven't gotten a chance to try implementing spine again as I've been pretty busy with work all week. I will try it out this weekend and let you know.

Thanks a lot for the help, I really appreciate it!

Good News! I was able to get the runtime to work on Cocos2d-x!

Thanks for the help everyone!

For those who may have the same problem as me here is a detailed report of what I did:

Note: I am using a Mac with Xcode and so I am not sure if this will work with other IDEs.
Note: To save some confusion I have highlighted the folder paths from the cocos2d-x runtime obtained from github in red and the folder paths within the cocos2d-x Xcode project in blue.

  1. Downloaded the cocos2d-x runtime for from github.

  2. Created a new cocos2d-x project. (It doesn't need to be a new one, it can be an old one as well)

  3. In the new project, under libs/extensions/spine, I deleted all the file within this folder, but not the folder itself. Cocos2d-x projects already have spine's runtime ingrained within; however, the runtime is not the most up-to-date. This is the reason, I replaced it.

  4. In that same folder, I copied the contents of spine-cocos2dx/src/spine in.

  5. In the runtime that I downloaded, this is only part of the required files for the runtime to work properly. The remaining files are found in spine-c/src/spine/ and in spine-c/include/spine/. Copy those files into the same folder on Xcode (libs/extensions/spine) and this will give you the remaining headers to make the runtime work properly. (@[đã xóa], thanks for pointing this out to me, I was wondering where these files were)

I hope this helps!

Thanks for sharing! 🙂