不得不说,cocos2d-x的版本更迭真是快,而最新的cocos2d-x v3.0 Beta版本中包含了许多新的特性和与之前2.x版本不同的内容,虽然说,目前3.0只是beta版本,但目前很多游戏已经采用这个3.0版本了,估计3.0的最终版本也会很快推出。
从创建项目开始了解一下这个最新的3.0版本的一些新特性吧!
一、创建项目(针对在mac os x中进行开发)
在前面我有一篇文章 点击打开链接 已经介绍过在 cocos2dx 2.2 版本中创建项目只能是在终端中进行,对于习惯了在xcode中直接通过项目模板生成项目的来说,这样的方式的确是有点不太方便。
但是在cocos2d-x v3.0 Beta版本中,采用了一种比较人性化图形界面创建方式。
在这里 点击打开链接 有详细的新版本使用介绍。
下面我实践一下如何创建一个 cocos2dx for ios & osx 的项目。(有两种方式)
1、第一种,当然是延续了2.2版本之后的直接命令行创建,这个具体方法可以请参考我之前的文章。点击打开链接
Example:
$ cd cocos2d-x/tools/project-creator
$ ./project-creator.py -n mygame -k com.your_company.mygame -l cpp -p /home/mygame
$ cd /home/mygame
cocos2d-x v3.0 Release Notes
Misc Information
- Download: http://cdn.cocos2d-x.org/cocos2d-x-3.0beta.zip
- Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.0beta/CHANGELOG
- API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.0beta/index.html
Requirements
Runtime Requirements
- Android 2.3 or newer
- iOS 5.0 or newer
- OS X 10.7 or newer
- Windows 7 or newer
Windows Phone 8 or newerN/A for the moment- Linux Ubuntu 12.04 (or newer)
Browsers via EmscriptenN/A for the momentMarmaladeN/A for the momentBlackBerryN/A for the moment
Compiler Requirements
- Xcode 4.6 (for iOS or Mac)
- gcc 4.7 for Linux or Android. For Android ndk-r9 or newer is required.
- Visual Studio 2012 (for Windows)
Highlights of v3.0
- Replaced Objective-C patters with C++ (C++11) patterns and best practices
- Improved Labels
- Improved renderer
- New Event Dispatcher
- Physics integration
- New GUI
- JavaScript remote debugger
- Remote Console support
- Refactor Image - release memory in time and uniform the api of supported file format
- Automatically generated Lua bindings, add LuaJavaBridge and LuaObjcBridge
- Templated containers
Features in detail
C++11 features
Feature added in v3.0-pre-alpha0
A subset of C++11 features are being used in cocos2d-x:
std::function
, including lambda objects for callbacks- strongly typed enums, for most of the cocos2d-x enums and constants
std::thread
for threadingoverride
context keyword, for overriden methods
std::function
CallFunc
can be created with anstd::function<void()>
CallFuncN
can be created with anstd::function<void(Node*)>
CallFuncND
andCallFuncO
were removed since it can be created with simulated withCallFuncN
andCallFunc
. See ActionsTest.cpp for more examplesMenuItem
supportsstd::function<void(Node*)>
as callbacks
CallFunc
example:
MenuItem
example:
strongly typed enums
Feature added in v3.0-pre-alpha0
Constants and enums that started with k
, and that usually were defined as