Game Development Reference
In-Depth Information
the code changes, you should also connect the same Value Changed event of the Seg-
mented Control and name it sceneChanged .
This concludes the user interface design part of this project. Now let's move on to
hooking up cocos2d.
Start Your cocos2d Engine
If you followed the user interface design part, you'll find two empty methods called
switchChanged and sceneChanged in the ViewController.m class imple-
mentation file, next to some other boilerplate code that was added by the View-based
Application template.
The first step is to get cocos2d up and running. One thing that's comfortable when
working with cocos2d projects created from one of the cocos2d templates is that you
rarely need to add a header file to any of your classes. That's because the cocos2d.h
file is imported in the project's prefix header. Because this is not the case in the View-
based Application template, open the ViewBasedAppWithCocos2D-Pre-
fix.pch file in the Supporting Files group and add the cocos2d header:
#import < Availability.h>
#ifndef __IPHONE_4_0
#warning "This project uses features only available in iPhone SDK 4.0 and later."
#ifdef __OBJC__
#import < UIKit/UIKit.h>
#import < Foundation/Foundation.h>
#import "cocos2d.h"
Now open the AppDelegate.m file. Because this app delegate class was created by
Apple's Single View project template, cocos2d isn't being initialized. You have to add
the necessary cocos2d startup code manually. You need to add the highlighted code in
Listing 15-7 to the didFinishLaunchingWithOptions method.
Search Nedrilad ::

Custom Search