Shinigamae
Shinigamae

Reputation: 862

Create a project with Storyboard, Cocos2D and ARC enabled

I'm using XCode 4.5.2 to create an iOS universal application.

I'd like to use its storyboard for my application. Normally, I create new project by choosing New > Project > Single view project > check Use storyboard.

Sometimes in my application, I need to use Cocos2D for complex animation (no need to interactive with it, only for presentation).

My animation was created using CocosBuilder which works with Cocos2D 2.0 and CCBReader library.

I tried to add Cocos2D to my existing project by:

  1. Adding Cocos2D folder (include Support, Platforms, kazmath folders).
  2. Try thing like edit -fno-obj-arc to those *.m files in Build Phases/Compile Sources.

But when I build project, the ARC errors are still there.

#Question:

  1. How could I implement Cocos2D into existing XCode 4.3/4.5 project?
  2. If I create a Cocos2D template project, could I activate ARC for rest of my project, those non-Cocos2D classes?

I successfully created an project with Cocos2D inside a UIView from a Cocos2D template as Ray's post but now I want things (may be) a little more complicated.

Upvotes: 4

Views: 2124

Answers (3)

Shinigamae
Shinigamae

Reputation: 862

With many help from @Setrio, @LearnCocos2D and lot of Googling, I finally fixed it.

My project is combined from Cocos2D, Storyboard, ARC enabled and CocosBuilder.

First, create a project with SingleView selection (ARC enabled of course).

Then download the Cocos2D ARC enabled here https://github.com/LearnCocos2D/cocos2d-iphone-arc-templates thanks to Steffen!

Add its libs into your project as pointed out here http://www.learn-cocos2d.com/2012/04/enable-arc-cocos2d-project-video-tutorial/ (brilliant, works like charm)

Create storyboard with Cocos2D as this tutorial (sample included) http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/

All things work together now. Beautiful. I love Cocos2D :)

Upvotes: 5

Sebastián Castro
Sebastián Castro

Reputation: 1408

I found this link/tutorial useful for a project similar to this one.

http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/

Basically you add support for cocos2d inside the view controllers. You have to use cocos2d as a library and that solves most of the issues.

Upvotes: 1

Sylvan
Sylvan

Reputation: 536

  1. I don't know off the top of my head.
  2. Yes, I have done this very thing with my latest Cocos2D-iOS project. I converted my project to ARC with the automatic refactoring tool, and I simply excluded all the Cocos2D library files from the process. for the most part the refactoring went smoothly and my project was up and running again in no time.

Upvotes: 1

Related Questions