Iphone game development is a very attractive prospect for any company. We evaluated several engines oolong, unity and cocos2d. Out of the three cocos came out to be the most promising for a 2D platformer, side shooter or a tower defense game. In this blog we discuss how the engine is sturctured and how to get started with the development on cocos2D.
The engine is basically divided into a Director which looks over all of the resource management. It is a singleton class which ensures that only one instance of director is in use. It is the starting point of any application that use cocos2d. So first we create a windows based application in our Xcode project creation wizard. Then in the application delegate class of our iphone game project we add the following code.
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window setUserInteractionEnabled:YES];
[window setMultipleTouchEnabled:YES];
[[Director sharedDirector]setDeviceOrientation:CCDeviceOrientationLandscapeLeft];
[[Director sharedDirector] setDisplayFPS:YES];
[[Director sharedDirector] attachInWindow:window];
[window makeKeyAndVisible];
Scene *gamesScene = [Scene node];
[[Director sharedDirector] runWithScene:gamesScene];
We ensure that we include the file cocos2d.h to ensure there are no compilation errors. The next step is to ensure that we link our application to the cocos2d libraries. To do that we go to Project> Edit Project Settings > Linker Search paths and set the path of the cocos2d library for linking. Hit the build and ensure there are no linker errors. And you would have your first cocos2d starter app ready.
I will be posting the code and screenshots of the process very soon. Till then keep on reading.
Alok Rao
Softway Solutions, Inc
Chief Software Architect
www.softwaysolutions.com
Thursday, July 2, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment