Build a quick cocos2d-x build environment under Mac

Source: Internet
Author: User
Tags lua sublime text

Objective

Although I have written a lot of cocos2d-x related tutorials and documentation, but this is my first contact with Quick, the first contact with Lua, so this tutorial I will stand in a beginner's perspective (see here is not to look at me, haha, don't cut!) Although the first time, but I have a lot of Quick big God, Liao greatly also in the next office, maybe sprinkle a big God he knows all the points of his own to give!), all-round analysis of the learning process of quick, and with everyone to learn how to use Quick-cocos2d-x Develop a game that belongs to oneself, package teaches the package will of OH.

Okay, so let's get to the bottom of it.

What is Quick-coco2d-x?

First of all, want to understand quick-coco2d-x must first know what cocos2d-x is, but I think about the introduction of cocos2d-x here do not need me to nonsense, after all, so cow game engine should be a bit famous!

Second, since Cocos2d-x is using the C + + language, and C + + has a high demand for developers, developers have gradually started to turn the Cocos2d-x C + + interface into Lua interfaces, thus deriving the Cocos2d-lua version. and Quick (Quick-coco2d-x) is a luxury enhanced and extended version of Cocos2d-lua, which overrides issues such as supporting code, resolving memory leaks, and only using global functions for callbacks. Quick enables developers to write games in a simple, easy-to-understand scripting language, and greatly improves development efficiency. Now Liao's big quick team has also taken over the development and maintenance of Cocos2d-lua, so the future of quick and Cocos2d-lua will be expected to be completely merged together.

The quick-coco2d-x version used in this tutorial is v3.3 Final, and you can find the corresponding and install the program in the civil network in the Cocos engine.

Note: Do not install the Quick in the root directory, or in a path with spaces or Chinese. In addition, Quick-cocos2d-x requires Python support, so check to see if your PC is loaded with Python by entering the Python command line in the terminal, if not installed, download the 2.x version of Python first.

After the Quick installation is complete, you can find two names of setup_mac.sh, setup_ in its root directory. Win.bat's batch scripts, which are scripts that build the Mac and Windows development environment, can automatically configure the Quick environment for you, depending on the needs of your system. After that, we can double-click the Player3 icon in the installation directory (which will generate the player's shortcut key on the Windows desktop), and start the simulator with the quick. In this simulator interface, we can create, open, and run projects, while also viewing many of the sample projects that have been brought with Quick.

For more information on Quick use, refer to the README file in the installation directory.

Quick-coco2d-x Development Tools

In general, we often use the Cocos Code IDE as a development tool to quickly develop the game, where the Cocos code IDE is an Eclipse-based cross-platform IDE that is specifically prepared for Cocos2d-x Lua & JavaScript Developers , through the IDE you can easily create game engineering, write and support debugging code on different platforms, real-time view of the effect of the changes in the code, and eventually released directly into a shelf-ready installation package.

However, recently learning Quick when listening to colleagues and a lot of user feedback said: Quick-coco2d-x v3.3 Final This version has some bugs on the Cocos Code IDE, and the execution is relatively slow. So in the great God's recommendation, this tutorial we do not choose the Cocos Code IDE as a development tool, but use another efficient way to complete the development of the Parkour game--sublime + Quickxdev.

Of course, if you want to use the Cocos code IDE is still possible, its installation and use of instructions can refer to: Cocos Code IDE + quick-cocos2d-x Rapid development of the game article.

Installation configuration for Development tools

Sublime text is a code editor with a beautiful user interface and powerful features, as well as an advanced text editor for HTML and prose, and many of its features depend on its powerful plug-in system. Sublime text supports the Lua language, but it does not have a function like code hints, so to use Sublime text to develop quick-coco2d-x programs quickly, we must install a powerful Quickxdev plugin.

Sublime text is: http://www.sublimetext.com/, download directly after installation.

Quickxdev: Http://git.oschina.net/lonewolf/QuickXDev, download it and then rename it to Quickxdev, then put the Quickxdev folder into the sublime Text in the Packages directory (can be opened by sublime Text->preferences->browse packages).

Then open Preferences->package Settings->quickxdev->settings–default in turn, as shown in:

Copy the contents of the section to Preferences->package Settings->quickxdev->settings–user (User is blank at this time), and in the "Quick_cocos2dx_root" After the entry, set the installation path for Quick-coco2d-x, as shown in:

When the settings are complete, the user's content overrides the settings under Default.
Note: The path above should be your own installation path, and if it is a Windows system, the path will look like this:

1."quick_cocos2dx_root":"D:\\Quick\\quick-3.3"

New Project

Once the development tools are ready, we can begin to create our project.

Starting with the quick Player3, you can see a lot of quick examples from the Sample tab here, and for starters, a look at how these examples are used will help us learn quick, and it's also a great way to quickly learn quick. Its interface is as follows:

Then we create a new project, click "New Project" on the interface, the player will automatically switch to the new project interface.

After setting the new project's storage path, package name, screen orientation, and whether to copy the C + + source code, we can create the project by clicking on the "Create Project" button in the lower right corner. It is important to note that if your project does not involve the C + + section, you can uncheck the "Copy Source Files" item so that the project can be created faster.

When you click the Create Project button, you will notice that the Create Project button in the lower right corner becomes "Open." and a terminal window appears showing the results of creating the project. When the terminal window display is created, we can click "Open ..." Open the project.

A project that is created by default is actually the "Hello World" program that programmers are most familiar with, and then we can write our own games based on this "Hello World" program.

Each new quick program comes with a console window, as shown in. This console window is the Player's output window, which includes your print log and crash log, and when your program fails, its output log will be a good proof.

Project Catalog Analysis

In order to learn quick program development faster and better, it is necessary to understand its project structure, so let's look at the directory structure of the engine and the new project in turn.

Engine Catalog Structure Analysis

Open the Quick installation directory, as shown in the following structure:

    • Build: This directory is the project storage directory for cocos2d-x.
    • Cocos: The folder contains most of the engine's library files, including: 2d, 3d, sound, base library, math library, physical library and so on a series of related class files.
    • Docs: This folder contains documentation for the engine's API documentation, the release of the document (the latest version changes, the running environment requirements, the compilation environment requirements, and how to run the relevant commands for the test case), the Cocos Programming specification, and so on. It allows us to view the code API for the engine, as well as the latest version of the changes introduced, the quick run environment requirements, the compilation environment requirements and how to run the test case related commands. Many of the files inside are in HTML and MD format.
    • Extensions: This is primarily a GUI extension library.
    • The
    • external contains a third-party library of physics engines, box2d and Chipmunk, a third-party library of databases, a sqlite3, a third-party library of networks, webp,websockets, and some other third-party libraries, such as code conversion libraries, data format libraries, and so on. The
    • licenses contains the various license files used in the engine. The SPIDERMONKEY-JS operating environment used in the License_spidermonkey,spider engine requires this license, which applies to several MPL/GPL/LGPL licenses License_chipmunk,license_ Js,license_lua and so on. Under these licenses, the engine can make arbitrary copies and modifications to the corresponding source code.
    • Quick: This is the Quick Engine code. It contains the batch tool for creating new projects for each platform, the core directory of the Quick framework, 2DX and some other dependent C + + files, template engineering, Quick's examples, and so on Quick's core files. The User Guide for
    • Readme.html/readme.md:quick, the installation, use, creation, and so on of quick can be obtained here, which in fact corresponds to the directory of documents in Docs.
    • setup_mac.sh: Build a script for your Mac development environment.
    • setup_win.bat: script to build the Windows development environment. The
    • Tools:quick is used as a tool for luabinding to export custom C + + classes.
    • Version: The edition is marked.
Structure analysis of new project directory

Open the directory for the new project, and let's analyze the directory structure of the new project, as shown in the following structure:

    • Config.json: Project information configuration file.
    • Debug.log: The project log, which is the output of all the log files for the Print console window.
    • Frameworks: Store Cocos2d-x engine core code and various platform runtime resources.
    • Res: the folder where the project resources are stored, that is, all the images, fonts, audio and other resources used in our game development are put here.
    • Runtime: Stores the precompiled run-time library.
    • SRC: The project source folder, that is, all the. Lua files in the game are put here.

The above directory res and SRC folder is the most wanted, in development we just need to operate on the contents of these two folders, you can realize the development of the game.

In the SRC folder of the new project, now you can see some. lua files, these are the LUA code for our project. Next we briefly introduce the functions of the following src:

    • Cocos:cocos Engine Code
    • The core of Framework:quick, a set of frameworks built on the basis of cocos2d-x
    • Config.lua: Engineering configuration files, including resolution adaptation information
    • Main.lua: Project Entrance
    • App: Project interface and other files, store our game code
      • Myapp.lua: The first interface of a game
      • Scenes: folder to store the game's various scene codes
        • Mainscene: The first scene of a game

In game development, when we need to modify and add the interface, we just need to add the scene to the corresponding folder.

Well, even if this chapter is finished, the next chapter will explain the code structure and usage of each LUA file in the new project, and begin the development of new games.

This series for the Cocos engine in the Civil Service Network Tutorial Group, the original tutorial reproduced please indicate the source. Thank you

I. I know that you must have Xcode installed on your computer (without downloading it yourself), open Xcode and turn on the Preferences dialog (Commond +). If a dialog box appears after opening, install Commond line tools directly:

If you are like this ....

For more than 10.9 of your OS X system version, how do I install Commond line tools? That's even easier.

Enter the terminal and type directly into the command line:

Xcode-select--install

Then, you will be prompted to select the installation:

Two. Download quick Cocos2d-x The current Quick cocos2d-x stable version is 2.2.1, download link: http://cn.quick-x.com/?page_id=198

Three. After the download is complete, unzip it to the desktop, start the terminal, enter:

Touch ~/. Bash_profile

Open ~/. bash_profile-a TextEdit

Enter confirm, and then type in the new dialog box that appears:

Export android_ndk_root=<path_to>/android/android-ndk-r8e

Export ANDROID_SDK_ROOT=<PATH_TO>/ANDROID/ANDROID-SDK-MACOSX

Export Quick_cocos2dx_root=<path_to>/quick-cocos2d-x

Export cocos2dx_root=${quick_cocos2dx_root}/lib/cocos2d-x

Export Android_home=${android_sdk_root}

This contains the configuration of the Android environment variable, no Android environment terminal will prompt:

-bash:path_to:no such file or directory

Do not worry, no impact, such as:

Four. Start Xcode and add the Source Trees in preferences:

Where name and DisplayName are the same. Path is the Quick Cocos2d-x folder on your computer, and if you don't know it, teach you a way. Open the terminal, drag the Quick Cocos2d-x-rc folder in, the terminal will display its path, and then copy and paste.

After the completion of the above operation, the environment is completed, the following we create a project, open the terminal:

Input:

1. CD Desktop (because my Quick folder is on the desktop)

2. CD QUICK-COCOS2D-X-2.2.1-RC

3. CD Bin

4../create_project.sh-o landscape com. Reventon.Game.testGame

-O is used to specify the screen orientation, landscape for horizontal screen, portrait for vertical screen. Testgame is the name of the project (not including the previous.)

After the project is created, its path is: Quick-cocos2d-x-2.2.1-rc/bin/testgame

Open the Xcode file under the Proj.ios folder and run the project to see HelloWorld.

Build a quick cocos2d-x build environment under Mac

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.