I literally have been pulling my hair out over this for a few days now. I am simply trying to implement Cocos2D into my UIKit app but I am not sure which files I need. I know to download it from http://www.cocos2d-iphone.org/ so I did, I open up the cocos2d-ios .xcodeproj but I have absolutely no idea which files to drag into my to properly implement it in my app.
I really need help with this!!!!
Thanks,
MyApps
You need to copy the entire cocos2D library into your project (all the files from the unarchived download).
You can then #import "cocos2D.h" into your view controller and assign your EAGLView (create one in the view controller if your project doesn't have one already) to cocos2D
(eg: [[CCDirector sharedDirector] setOpenGLView: glView];)
I know it's a bit backward, but it might be easier to create a template cocos2D project and from there migrate your existing files to the new project (your mileage may vary depending on how complex your existing project/build is).
Related
I am following a hello world tutorial for xcode. I opened my LaunchScreen.xib file in Xcode6, here is how it looks like:
But according to the tutorial, there needs to be an Objects tab. Can anyone tell me where i can find it?
Thanks
Edit: Here is how it looks like in the tutorial:
I want to find my AppDelegate.h file but i cannot find it.
The Objects section of the document outline has been removed. Everything that was formerly under it is now a top-level item in the document outline. So everything that you now see in the outline that isn't under the “Placeholders” section would formerly have been under “Objects”.
Xcode's project templates have changed since your tutorial was written. When your tutorial was written, the template used a xib file that contained the app delegate and the window. Now, the template uses a storyboard. The system instantiates the app delegate and the window automatically and loads the initial view controller and its view from the storyboard.
The xib you are looking at (LaunchScreen.xib) is a new feature for iOS 8 that replaces the launch image PNGs you must use in older versions of iOS. It is not the xib you are looking for to work through your tutorial.
It would be possible to modify your project to match what the tutorial assumes you have, but doing so is probably not worth the effort. Look for a tutorial written for Xcode 5.1 or later that assumes you are starting with a storyboard.
How you solve issues with merging storyboard.
I found few suggestion:
First - using xib instead storyboard
Second - using different storyboards for different views
Third - write code UI instead using UI builder
I think all of this solutions have a chance to live.
I think storyboard is a good solution for development, but I also think that apple has made mistake created all scenes in one file. I think better way have different files for each scene that is in storyboard and if someone modified one scene it does not affect on other scene because each scene has separate file. I hope they will implement it in new SDK.
But right we have what we have and I what to ask all how you resolve merging conflict when you work as a team. Because my last experience 170 merge issues in UIStoryboard file and honestly it simple to resolve "by hand" instead of using Xcode merger =)
Thanks for all recommendation.
You can have storyboards inside other storyboards.
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:
Adding Cocos2D folder (include Support, Platforms, kazmath folders).
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:
How could I implement Cocos2D into existing XCode 4.3/4.5 project?
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.
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 :)
I don't know off the top of my head.
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.
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.
Not knowing that Storyboards are iOS5 only I created project that could be run even on iOS 2.0, but now I can't compile it with target lower than iOS5. Is there an easy way to go back to simple XIB file?
I don't think there's an automatic way to downgrade. Create new xib files for each view controller that needs them and link their view with the appropriate .h file. You should be able to copy and paste your whole UIView container view from storyboard to an xib though so it's really not that bad.
EDIT:
Also, I recently had to do this myself and a few things that weren't immediately obvious to me were that I also had to create a MainWindow.xib file, change your application plist, main.m, and my app delegate. Was definitely more complex than I expected but can confirm it can be done.
I have downloaded the latest cocos2d from their site, and I have unzipped it. Now I am confused exactly how to implement it into an already existing project. What files do I drag over and is there anything else I have to do besides that?
Thanks!
You can link cocos2d into your project as shown here. He uses a special version that supports arc, but it works in exactly the same way with the original version. Then in a next step make sure that you import all the important libraries:
QuartzCore.framework
OpenGLES.framework
AVFoundation.framework
UIKit.framework
Foundation.framework
CoreGraphics.framework
If you use sound you also will need:
OpenAL.framework
AudioToolbox.framework
libcocosDenshion.a
Now you need to set up a rootview that supports OpenGL. Look at the Hello World example how they did this there. You should now be able to implement and display Cocos2d scenes on screen.
Here straight from the source:
Cocos2D tutorial