0

I got an existing Objective-C project. Now I decided to rewrite some code and add Cocos2d to it. I know this framework for a long time and I recently discovered that they stopped the support for Cocos2d and created a new version called Cocos2d-x. There I found the Swift library and I asked me how to use the Cocos2d-Swift framework in my existing Objective-C project ? A step by step tutorial would be great. I searched a bit in the internet and found this: Stackoverflow Link

But since the post is from 2011 it does not cover how to add the swift library, since Swift wasn't introduced at this moment.

Community
  • 1
  • 1
dehlen
  • 7,325
  • 4
  • 43
  • 71
  • Short history: the Cocos2D-X project was created by Chinese company Chukong (http://en.chukong-inc.com/tag/cocos2d-x/) to provide a C++ version of largely the same API. Cocos2d-iphone lead developers were hired by Zynga, but eventually Apportable took over supporting the project and created v3 (aka cocos2d-swift), while the original lead devs went on to work on the -x project. Both projects subsequently took different directions in terms of API with their respective v3 versions. – CodeSmile Jan 30 '15 at 14:55
  • As for integration: like Yves said, get SpriteBuilder to create a new project, then add your existing resources into it. Currently there's no info that I know of on how to make a mixed UIKit / Cocos2D app, especially not if you plan on starting with the UIKit/Storyboards part before actually initializing the cocos2d view. – CodeSmile Jan 30 '15 at 14:58

1 Answers1

0

Cocos2d-swift is a bit of a misnomer : it is currently written in objective-c. The software is now distributed with SpriteBuilder, that is why there is no 'install.sh' as there used to be. So integrating it into your project should not be too difficult. Use SpriteBuilder (from the AppStore) to create a 'blank' SB project, and see how cocos2d is integrated in there. Then, what you see is what you integrate !

caveat : Cocos2d is now ARC, so it is best your project defaults ARC. Otherwise you will have to do a lot of Xcode click-click-click to make the reference count strategy file specific.

YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48
  • I already have ARC enabled. I'll get to my Mac in a few hours and then I'll try your suggestions. If I find a solution I'll post ASAP. – dehlen Jan 30 '15 at 14:09
  • I dont use SB myself, but that is how i 'upgraded' three projects. Worked like a charm :) best of luck. – YvesLeBorg Jan 30 '15 at 14:11
  • 1
    I decided to go with SpriteKit since it has most of the functions I needed from cocos2d and the integration will be way easier. However I accepted your answer, since this is probably the right way to go and I thought I'd give you credit for that. – dehlen Jan 30 '15 at 20:38
  • @dehlen thanks for the credit. To your point, and Stefen's remarks, my next project will probably be away for cocos2d too. Too many prospects for appropriation of the techno, too many arbitrary mindless changes to the API, seems to be dedicating itself to an immature `no programming` environment. Might as well go with a full featured kit ... call it Unity. CSharp not that bad either, and IntelliJ has a bang-up IDE too. – YvesLeBorg Jan 30 '15 at 20:51
  • After you setup your project, kick the tires of AppCode ... once you go J you never go back :) – YvesLeBorg Jan 30 '15 at 21:54
  • no i would not like to automatically move this discussion to chat? – YvesLeBorg Jan 30 '15 at 21:59
  • I didn't offer that... It's Stackoverflow offering that because we commented multiple times. Anyway my question is answered, so : Closed – dehlen Jan 30 '15 at 22:00