iphone - Cocos 2d application structure -



iphone - Cocos 2d application structure -

i new cocos2d , want know thing cocos2d application structure. here code in appdidfinishlaunching function in default template.

- (void) applicationdidfinishlaunching:(uiapplication*)application { // init window window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; // seek utilize cadisplaylink director // if fails (sdk < 3.1) utilize default director if( ! [ccdirector setdirectortype:kccdirectortypedisplaylink] ) [ccdirector setdirectortype:kccdirectortypedefault]; ccdirector *director = [ccdirector shareddirector]; // init view controller viewcontroller = [[rootviewcontroller alloc] initwithnibname:nil bundle:nil]; viewcontroller.wantsfullscreenlayout = yes; // // create eaglview manually // 1. create rgb565 format. alternative: rgba8 // 2. depth format of 0 bit. utilize 16 or 24 bit 3d effects, ccpageturntransition // // eaglview *glview = [eaglview viewwithframe:[window bounds] pixelformat:keaglcolorformatrgb565 // keaglcolorformatrgba8 depthformat:0 // gl_depth_component16_oes ]; // attach openglview director [director setopenglview:glview]; // // enables high res mode (retina display) on iphone 4 , maintains low res on other devices // if( ! [director enableretinadisplay:yes] ) // cclog(@"retina display not supported"); // // important: // if rotation going controlled uiviewcontroller // device orientation should "portrait". // // important: // default, template supports landscape orientations. // edit rootviewcontroller.m file edit supported orientations. // #if game_autorotation == kgameautorotationuiviewcontroller [director setdeviceorientation:kccdeviceorientationportrait]; #else [director setdeviceorientation:kccdeviceorientationlandscapeleft]; #endif [director setanimationinterval:1.0/60]; [director setdisplayfps:yes]; // create openglview kid of view controller [viewcontroller setview:glview]; // create view controller kid of main window [window addsubview: viewcontroller.view]; [window makekeyandvisible]; // default texture format png/bmp/tiff/jpeg/gif images // can rgba8888, rgba4444, rgb5_a1, rgb565 // can alter anytime. [cctexture2d setdefaultalphapixelformat:kcctexture2dpixelformat_rgba8888]; // removes startup flicker [self removestartupflicker]; // run intro scene [[ccdirector shareddirector] runwithscene: [helloworld scene]]; }

my question when add together kid ccdirector how thing can shown on screen when ccdirector director never added on window.view have next lines of code

// create openglview kid of view controller [viewcontroller setview:glview];

this set view of rootviewcontroller glview , before setting

[director setopenglview:glview]; means openglview of director set glview.

do dont have add together director viewcontroller assuming can added whatever add together director visible on screen.

my question how scene should visible on iphone screen when have never added ccdirector on rootviewcontroller.

ccdirector setting glview view of rootviewcontroller. next drawing made using opengl. in glview. cocos2d classes cclayer, ccnode, ccsprite , on have nil uiview or uiviewcontroller

iphone cocos2d-iphone

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -