When using the Cocos2d-iPhone framework to develop IOS games, for each scene (ccscene) Editing is more troublesome, fortunately there are foreign cattle provide a very good scene Editor-cocosbuilder. Below I will detail the use of cocosbuilder combined with Cocos2d-iPhone framework.
Frame: Cocos2d-iPhone
Tool: cocosbuilder 2.0 Beta, xcode4.3
1. Open xcode and create a cocos2d IOS Project
2. Include. create a folder named ccbuilder where the xcodeproj file is located, and then create two folders named projects and resources under the new folder to place the cocosbuilder project and resource files.
3. Open the installed cocosbuilder, open new under the File menu, select new project, create a cocosbuilder project, and save the new project to the/ccbuilder/Projects folder. Open the project setting menu under the File menu, as shown in
Click "+" and add the/Projects and/resources folders respectively.
Then in publish directory, select the resource folder of the previously created xcode project.
Check "flatten paths when publishing" and "Publish to zip file" to reduce the size of the generated file.
Click "done ".
4. Open new under the File menu, select new file, create a cocosbuilder file, and save the new file to the/ccbuilder/Projects folder, for example, the new CCB file is startgame. CCB, now you can choose to add cocos2d elements under the object menu.
5. After editing the CCB file, click Publish under the filepath. In this example, a ccb.zip file is generated under the resource file of the xcodeproject and added to the reference of xcode.
Cat6 is the generated ccb.zip file. You need to add the file in the attachment to the xcode project, that is, add ccbreader (used to read the CCB file) and ssziparchive (used to extract the ZIP file. In addition, you need to change Preprocessor macros under build settings of the xcode project and add a parameter "ccb_enable_unzip"
7. Before calling ccfileutils [ccfileutils sharedfileutils] In cocos2d, call [ccbfileutils sharedfileutils].
- Director _ = (ccdirectorios *) [ccdirector shareddire];
-
- Director _. wantsfullscreenlayout = yes;
- [Ccbfileutils sharedfileutils];
-
- // Display FSP and SPF
- [Director _ setdisplaystats: Yes];
-
- // Set FPS at 60
- [Director _ setanimationinterval: 1.0/60];
-
- // Attach the openglview to the Director
- [Director _ setview: glview];
-
- // For rotation and other messages
- [Director _ setdelegate: Self];
-
- // 2D projection
- [Director _ setprojection: kccdirectorprojection2d];
- /[Director setprojection: kccdirectorprojection3d];
-
- // Enables high res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
- If (! [Director _ enableretinadisplay: Yes])
- Cclog (@ "retina display not supported ");
-
- // Create a navigation controller with the director
- Navcontroller _ = [[uinavigationcontroller alloc] initwithrootviewcontroller: Director _];
- Navcontroller _. navigationbarhidden = yes;
-
- // Set the navigation controller as the Root View Controller
- /[Window _ setrootviewcontroller: rootviewcontroller _];
- [Window _ addsubview: navcontroller _. View];
-
- // Make Main Window visible
- [Window _ makekeyandvisible];
-
- // Default texture format for PNG/BMP/tiff/JPEG/GIF images
- // It Can Be rgba8888, rgba4444, rgb5_a1, rgb565
- // You can change anytime.
- [Cctexture2d setdefaultalphapixelformat: kcctexture2dpixelformat_rgba8888];
-
- // If the 1st suffix is not found and if Fallback is enabled then fallback suffixes are going to searched. If none is found, it will try with the name without suffix.
- // On iPad HD: "-ipadhd", "-iPad", "-HD"
- // On iPad: "-iPad", "-HD"
- // On iPhone HD: "-HD"
- Ccfileutils * sharedfileutils = [ccfileutils sharedfileutils];
8. Use CCB files
- [Ccbreader unzipresources: @ "ccb.zip"];
- // Use the ccbreader to load the hellococosbuilder scene
- // From the CCBI-file.
- Ccscene * scene = [ccbreader scenewithnodegraphfromfile: @ "startgame. CCBI" Owner: Self];
- // Add the scene to the stack. The director will run it when it automatically when the view is displayed.
- [Director _ pushscene: Scene];
In this way, you can use it normally.
This article from the "open wilderness" blog, please be sure to keep this source http://1127341.blog.51cto.com/1117341/898754