background preloader

Integrate with UIKit

Facebook Twitter

Integrating with existing UIKit Application fails - How can I do it? Mokargas @mokargas Hey all. I have an existing UIKit based application, which is basically a few UIViews. One of these UIView’s needs to be an animated cocos2d layer. I’ve just added the following code to my app delegate in an attempt to get anything to appear – it’s basically what lies within the standard new templates app delegate for a new cocos2d project. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{CC_DIRECTOR_INIT(); application.statusBarStyle = UIStatusBarStyleBlackOpaque;application.idleTimerDisabled = YES;window = UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds;CCDirector *director = [CCDirector sharedDirector]; return YES;} Problem is, this crashes immediately with no console error message or log on either the simulator or device.

I only want my scene to run on one UIView in my app, any other time should just be a bunch of standard UIKit items. Benihana Participant @benihana Where do you initialize your scene? Cocos2D Embedded In A Cocoa Touch App. I just completed this project for the new book chapter about embedding UIKit views/Cocoa Touch in a Cocos2D application. In that case I embedded the Cocos2D view in the View-based Application template and added some controls to start/stop the cocos2d view and change scenes. Here’s the result: It also correctly auto-rotates. But I noticed an odd bug with auto-rotation enabled for all orientations: the view is designed in portrait mode. If I start the App on my iPod Touch 4 while holding the device in landscape mode, then rotate back to portrait mode once the app has started and enable the cocos2d view, for some reason this causes my device to reboot!

I see a transparent white color drawn over the entire screen before the screen goes black and the Apple logo appears. If anyone has any idea what might be causing this behavior, please let me know. I’m guessing it might have to do with the EAGLView initialization, since I rely on Interface Builder to initialize the view. Learn cocos2D Game Development with iOS 5 > Learn cocos2D Game Development with iOS 5 > Chapter 15: Cocos2d with UIKit Views - Pg. 401. Learn cocos2d Game Development with iOS 5 provides a rock-solid introduction to the cocos2d iPhone and iPad game apps engine and related tools.

It focuses on the process of creating several game apps made entirely using cocos2d with little or no use of the iOS 5 SDK and OpenGL code. By creating 2-3 sample game apps while working through the book, you'll learn key concepts of the cocos2d game engine and relevant tools like Zwoptex (TextureAtlas), ParticleDesigner (particle effects), and others. The example games are modeled after popular App Store games, so they're relevant, recognizable, and immediately fun and inspiring. The games increase in complexity and highlight common questions for cocos2d beginners. It is assumed that the reader has previous programming knowledge, though not necessarily with Objective-C. Cocos2d and UIKit integration. Integrate cocos2d and UIKit.

Iphone - Integrating Cocos2D with UIKit. Iphone - Cocos2d vs UIKit. Tips:cocos2d_and_uikitlayer – cocos2d for iPhone. Cocos2d and UIViewControllers « The Brenwill Workshop. Help us continue to provide great software! If you find this software useful, please consider making a donation to help us continue to provide and support quality products like this. This cocos2d framework package is a wonderful framework for working with OpenGL ES within iOS.

Since it focuses on high performance OpenGL ES code, for the most part cocos2d bypasses Apple’s Cocoa UIViewController hierarchy. This makes sense, since within iOS, OpenGL ES usually plays out on a single UIView, and typically in a single display orientation, so there’s usually not much to control. However, there are occasions where the functionality provided by UIViewController can be quite useful. In particular, the following functionality is best handled by adding a UIViewController into the mix: Auto-rotation – in some games, or other OpenGL ES applications, it makes sense to change the orientation of the application display to match changes in the orientation of the physical device. Examples Quick Start. Using cocos2d in an UIKit-based app. I know this must be a quite frequently asked question, and I have searched the forum and found some threads that hint that this is possible, but I have hard time finding concrete details.

I have developed some 2D games for the iPhone using pure uikit. However, we are hitting its limits (eg. we would really want particle effects and other fancy features which are next to impossible to do with uikit) and we would like to start using something more powerful which uses OpenGL, and cocos2d seems to be like the perfect solution for that. Our games have plenty of menus. Main menus, game mode selection menus, options menus, achievement menus, high score menus (local and online), language selection menus… you name it.

The thing is that with uikit and interface builder I can go from nothing to having a prototype with all these menus fully working in a matter of a few hours. I can live with that with respect to the main game view, where the actual game action happens. How To Integrate Cocos2D and UIKit. This post is also available in: Chinese (Simplified) If you're new here, you may want to subscribe to my RSS feed or follow me on Twitter. Thanks for visiting! Build an app that is part Cocos2D, part UIKit! Cocos2D is a great framework, but sometimes it’s handy to implement some of your game with UIKit. For example, it’s often useful to design your main menu, settings pages, and the like with UIKit and just use Cocos2D for your main game logic. You also might find it handy to use UIKit controls on top of a Cocos2D scene – such as text fields, buttons, tab bars, or ad views.

In this tutorial, you’ll learn how to do exactly like this! This tutorial assumes you have some basic familiarity with Cocos2D and UIKit development. Getting Started Start by downloading the starter project we’ll be using for this tutorial. Go ahead and run the project and you should see the following: This project is a simple Cocos2D app that displays a set of calendars made by my lovely wife Vicki. Adding a MainWindow.xib. Cocos2D in UIKit. Runloop @runloop Hi all, I’m planning an update for my recent game Blockees. At present the whole game is written in Cocos2d. However, there are only 2 scenes that actually need to be OpenGL so I’m actually considering making the most of the app in UIKit and then just using Cocos2d for the scenes that actually require it.

I realise a lot of people will question my motives for doing such a thing so let me tell why I plan on doing this now. I’ve been experimenting and have it up and running so far but I am getting a bit of a lag each time I try and display a new view controller that has a cocos2d scene in it. I’ve a category on CCDirector with this method: - (EAGLView *)openGLViewWithFrame:(CGRect)frame{EAGLView *glView = [EAGLView viewWithFrame:framepixelFormat:kEAGLColorFormatRGBA8depthFormat:0]; [self setOpenGLView:glView];[self enableRetinaDisplay:YES]; return glView;} then in my controllers I add: - (void)viewDidAppear:(BOOL)animated{[super viewDidAppear:animated]; Cheers Dan hartem @hartem.

Post-A-Day #5, UIKit + Cocos2d – View Based Cocos2D Application » Learning Iphone. Cocos2D is awesome, and it even comes with some amazing templates to create 3 different kinds of projects. Vanilla version, one that combines Box2d(physics engine), and one that combines it with Chipmunk (physics engine). I see a lot of games that use Cocos2D exclusively from beginning to end, and by default that’s more or less how these templates will set you up. It can lead to problems down the line, but also it’s a mistake to think you should re-invent the wheel when it comes to UIDesign as apple has done a great job and users are comfortable and like their system.

Another feeling of mine, and I can’t fault Cocos2D for this, only myself is that for a while I was really getting good knowing the ins and outs of objective-c, but I was more or less stuck on HelloWorld when it came to UIKit. I ended up seeing my use of Cocos2D as a crutch, i fell back on doing everything via Cocos2D much too quickly. … If something goes wrong in the steps, i’m very sorry. Tags: iOS. Post-A-Day #5, UIKit + Cocos2d – View Based Cocos2D Application » Learning Iphone.