Scenario Editor cocosbuilder tutorial

Source: Internet
Author: User
  •  

    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].

    1. Director _ = (ccdirectorios *) [ccdirector shareddire];
    2.  
    3. Director _. wantsfullscreenlayout = yes;
    4. [Ccbfileutils sharedfileutils];
    5.  
    6. // Display FSP and SPF
    7. [Director _ setdisplaystats: Yes];
    8.  
    9. // Set FPS at 60
    10. [Director _ setanimationinterval: 1.0/60];
    11.  
    12. // Attach the openglview to the Director
    13. [Director _ setview: glview];
    14.  
    15. // For rotation and other messages
    16. [Director _ setdelegate: Self];
    17.  
    18. // 2D projection
    19. [Director _ setprojection: kccdirectorprojection2d];
    20. /[Director setprojection: kccdirectorprojection3d];
    21.  
    22. // Enables high res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
    23. If (! [Director _ enableretinadisplay: Yes])
    24. Cclog (@ "retina display not supported ");
    25.  
    26. // Create a navigation controller with the director
    27. Navcontroller _ = [[uinavigationcontroller alloc] initwithrootviewcontroller: Director _];
    28. Navcontroller _. navigationbarhidden = yes;
    29.  
    30. // Set the navigation controller as the Root View Controller
    31. /[Window _ setrootviewcontroller: rootviewcontroller _];
    32. [Window _ addsubview: navcontroller _. View];
    33.  
    34. // Make Main Window visible
    35. [Window _ makekeyandvisible];
    36.  
    37. // Default texture format for PNG/BMP/tiff/JPEG/GIF images
    38. // It Can Be rgba8888, rgba4444, rgb5_a1, rgb565
    39. // You can change anytime.
    40. [Cctexture2d setdefaultalphapixelformat: kcctexture2dpixelformat_rgba8888];
    41.  
    42. // 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.
    43. // On iPad HD: "-ipadhd", "-iPad", "-HD"
    44. // On iPad: "-iPad", "-HD"
    45. // On iPhone HD: "-HD"
    46. Ccfileutils * sharedfileutils = [ccfileutils sharedfileutils]; 

    8. Use CCB files

    1. [Ccbreader unzipresources: @ "ccb.zip"];
    2. // Use the ccbreader to load the hellococosbuilder scene
    3. // From the CCBI-file.
    4. Ccscene * scene = [ccbreader scenewithnodegraphfromfile: @ "startgame. CCBI" Owner: Self];
    5. // Add the scene to the stack. The director will run it when it automatically when the view is displayed.
    6. [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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.