axmol/docs/RELEASE_NOTES.md

280 lines
8.9 KiB
Markdown
Raw Normal View History

2014-05-20 07:56:33 +08:00
# cocos2d-x v3.1 Release Notes #
2014-01-07 08:33:14 +08:00
2014-01-07 08:26:48 +08:00
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
2014-01-07 08:23:06 +08:00
# Misc Information
2014-05-20 07:56:33 +08:00
* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.1rc0.zip
* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.1rc0/CHANGELOG
* ~~API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.0/index.html~~
* v3.0 Release Notes can be found here: [v3.0 Release Notes](https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.0/docs/RELEASE_NOTES.md)
2014-01-07 08:23:06 +08:00
# Requirements
## Runtime Requirements
* Android 2.3 or newer
* iOS 5.0 or newer
* OS X 10.7 or newer
* Windows 7 or newer
2014-05-20 07:56:33 +08:00
* Windows Phone 8 or newer
2014-01-07 08:23:06 +08:00
* Linux Ubuntu 12.04 (or newer)
* ~~Browsers via Emscripten~~ N/A for the moment
## Compiler Requirements
2014-05-20 07:56:33 +08:00
* Xcode 4.6 or newer for iOS or Mac
* gcc 4.7 or newer for Linux
* gcc 4.7 and ndk-r9 or newer for Android
* Visual Studio 2012 or newer for Windows (win32)
* Visual Studio 2012 or newer for Windows Phone 8
2014-01-07 08:23:06 +08:00
2014-04-21 14:50:27 +08:00
## How to run tests
2014-03-04 18:15:30 +08:00
### Mac OSX & iOS
* Enter `cocos2d-x/build` folder, open `cocos2d_test.xcodeproj`
* Select `iOS` or `OS X` target in scheme toolbar
* Click `run` button
### Android
2014-03-07 08:37:33 +08:00
You can run the samples...
2014-03-04 18:15:30 +08:00
2014-03-07 08:37:33 +08:00
**Using command line:**
2014-03-04 18:15:30 +08:00
$ cd cocos2d-x
2014-03-06 14:44:33 +08:00
$ ./setup.py
2014-03-04 18:15:30 +08:00
$ cd build
2014-03-14 15:01:11 +08:00
$ ./android-build.py cpp-empty-test -p 10
$ adb install cocos2d-x/tests/cpp-empty-test/proj.android/bin/CppEmptyTest-debug.apk
2014-03-04 18:15:30 +08:00
Then click item on Android device to run tests. Available value of `-p` is the API level, cocos2d-x supports from level 10.
2014-03-07 08:37:33 +08:00
**Using Eclipse:**
2014-03-04 18:15:30 +08:00
$ cd cocos2d-x
2014-03-06 14:44:33 +08:00
$ ./setup.py
2014-03-04 18:15:30 +08:00
$ cd build
2014-03-14 15:01:11 +08:00
$ ./android-build.py cpp-empty-test -p 10
2014-03-04 18:15:30 +08:00
Then
* Import cocos2d-x Android project into Eclipse, the path used to import is `cocos/2d/platform/android`
2014-03-14 15:01:11 +08:00
* Import `cpp-empty-test` Android project into Eclipse, the path used to import is `tests/cpp-empty-test/proj.android`
* Build `cpp-empty-test` Android project and run
2014-03-04 18:15:30 +08:00
### Windows
* Enter `cocos2d-x/build`, and open `cocos2d-win32.vs2012.sln`
2014-03-14 15:01:11 +08:00
* Select `cpp-empty-test` as running target
2014-03-04 18:15:30 +08:00
* Click run button
### Linux
$ cd cocos2d-x/build
$ ./install-deps-linux.sh
$ cd ../..
Then
$ mkdir build
$ cd build
2014-03-14 15:01:11 +08:00
$ cmake ../cocos2d-x
2014-03-04 18:15:30 +08:00
$ make -j4
Run
2014-03-14 15:01:11 +08:00
$ cd bin/cpp-empty-test
$ ./cpp-empty-test
2014-03-04 18:15:30 +08:00
2014-03-06 14:44:33 +08:00
## How to start a new game
2014-04-21 14:45:36 +08:00
Please refer to [ReadMe](../README.md). And there is a [document](https://github.com/chukong/cocos-docs/blob/master/manual/framework/native/getting-started/v3.0/how-to-start-a-new-game/en.md) for it.
2014-03-06 14:44:33 +08:00
2014-03-04 18:15:30 +08:00
2014-05-20 07:56:33 +08:00
# Highlights of v3.1
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
* `Sprite3D`, a new node to render 3D models
* Improved Shader subsystem
* New, unified, math library
* `ui::VideoPlayer`, a new node to play videos
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
# Features in detail
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
## Sprite3D
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
cocos2d-x v3.0 replaced `Node`'s 2x3 transform matrix with a 4x4 one. This feature allows you to transform any node in a 3d space.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
`Sprite3D` allows users to render a 3d model inside cocos2d. And since cocos2d-x already has 4x4 transform matrix, it is possible to move scale and rotate the `Sprite3D` in the x, y, and z axis.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
The API is like `Sprite`:
2014-03-07 08:37:33 +08:00
2014-05-20 07:56:33 +08:00
```c++
// v3.1 only supports the Wavefront file format
auto sprite3d = Sprite3D::create("mymodel.obj");
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
// if the material is not specified in .obj, you can override it with:
auto sprite3d = Sprite3D::create("mymodel.obj", "texture.png");
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
// Since Sprite3D is a regular node, you can add it into the scene like any other node
scene->addChild(sprite3d);
sprite3d->setRotation3D(Vec3(x,y,z));
2014-01-07 08:23:06 +08:00
```
2014-05-20 07:56:33 +08:00
## Improved Shader Subsystem
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
In order to support `Sprite3D`, we refactored our shader subsystem. The result is that we have an easier to use, yet more powerful shader system that can be used both for 2D and 3D.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
In v3.0, the class `GLProgram` was used both for holdin the _OpenGL program_ (shader), and also the shader state (uniforms and attributes).
2014-05-20 07:56:33 +08:00
That design had one big constraint: In order to add or remove an attribute or uniform, you had to subclass `GLProgram`.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
In v3.1, we decoupled the shader state from the shader. We added the `GLProgramState` class which holds the attributes and uniforms.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
The API is the following:
2014-01-07 08:23:06 +08:00
```
2014-05-20 07:56:33 +08:00
auto glprogram = GLProgram::create(...);
// it will automatically parse all the attributes and uniforms
// used by glprogram, and it will populate the glprogramstate dictionary
// with them
auto glprogramstate = GLProgramState::create( glprogram );
// How to set a uniform for Vec2 (Int, Texture, Vec3, Vec4, Mat4, are all supported)
glprogramstate->setUniformVec2("u_my_uniform", Vec2(x,y));
// or how to set it using a callback
glprogramstate->setUniformCallback("u_my_uniform", [](Uniform*uniform){
// do something
});
// How to set an attribute
glprogramstate->setVertexAttribPointer("a_my_attrib", 4, GL_FLOAT, GL_FALSE, 0, vertex);
// or how to set it using a callback
glprogramstate->setVertexAttribCallback("a_my_attrib", [](VertexAttrib*attrib){
// do something
});
2014-01-07 08:23:06 +08:00
```
2014-05-20 07:56:33 +08:00
By using this API it is possible to change the effect on a `Sprite3D` (or even an `Sprite`) without subclassing any cocos2d class!
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
Possible examples:
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
- Outline / Shadow / Glow effects
- Multi-texturing effects
- Sepia, Grey or other color effects
- and more
For a complete example, please see the [Shader - Sprite](https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.1rc0/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp) and [Shader - Basic](https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.1rc0/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp) examples.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
## New math library
2014-02-26 16:41:47 +08:00
2014-05-20 07:56:33 +08:00
cocos2d-x v1.0 only supported 2D features. So it made sense to use a 2x3 Transform matrix for the operations.
2014-02-26 16:41:47 +08:00
2014-05-20 07:56:33 +08:00
In cocos2d-x v2.0 we added OpenGL ES 2.0 support (no more built-in OpenGL matrix operations) so it made sense to use [Kazmath](https://github.com/Kazade/kazmath), a math library that replaced the OpenGL ES 1.0 functionality. Kazmath was used internally, and most of the users never used the Kazmath API at all.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
In cocos2d-x v3.0 we refactored the renderer and we exposed a bit more the Kazmath API to the users.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
And in v3.1, with `Sprite3D` we needed to expose even more the the Kazmath API. And it no longer made sense to have multiple math libraries inside cocos2d-x.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
The problems were:
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
* Part of the code was using the old 2D math library
* Part of the code was using Kazmath
* Part of the code was using ad-hoc math code
The goal was to use only one math library for cocos2d-x, with the following requirements:
* Easy to use, easy to mantain
* Proven
* In C++ if possible
So we took the [GamePlay3D](http://gameplay3d.org/) math library, we did some minor changes, and the cocos2d-x math code with it.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
How to use it:
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
```c++
// vector2
Vec2 vec2(10,20);
Vec2 other2(30,40);
auto ret = vec2.cross(other2);
auto ret2 = vec2 + other2;
auto ret3 = vec3 * scalar;
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
node->setPosition(vec2);
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
// vector3
Vec3 vec3(30,40,50);
node->setPosition3D(vec3);
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
// vector4
Vec4 vec4 = Vec4::ZERO;
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
// Matrix 4x4
auto identity = Mat4::IDENTITY;
node->setNodeToParentTransform(identity);
2014-01-07 08:23:06 +08:00
```
2014-05-20 07:56:33 +08:00
The good news is that the old API still works since we `typedef` the old classes and structs to the new math classes.
2014-03-07 11:48:39 +08:00
2014-05-20 07:56:33 +08:00
## New UIVideoPlayer
2014-05-20 07:56:33 +08:00
v3.1 has a new `Node` to play videos. The API is:
2014-05-20 07:56:33 +08:00
```c++
// VideoPlayer is under the "experimental" namespace since
// it only works for iOS and Android, and we might change its
// API in the future
auto videoPlayer = cocos2d::experimental::ui::VideoPlayer::create();
videoPlayer->setContentSize(Size(x,y));
videoPlayer->setURL("http://example.com/video.mp4");
videoPlayer->play();
```
2014-05-20 07:56:33 +08:00
## UI navigation
TODO
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
## Improved folder structure
2014-03-07 11:48:39 +08:00
2014-05-20 07:56:33 +08:00
In v3.0 we started a folder re-organization for cocos2d-x. Unfortunately we didn't have the time to finish it on time.
2014-03-07 11:48:39 +08:00
2014-05-20 07:56:33 +08:00
In v3.1 we finished the folder re-organization, and it looks like this:
2014-03-07 11:48:39 +08:00
2014-05-20 07:56:33 +08:00
cocos/: includes cocos2d.cpp and other build files
cocos/2d/: includes base nodes, 2d nodes and related objects like Node, Scene, Sprite, etc.
cocos/3d/: includes 3d nodes and related objects like Sprite3D
cocos/audio/: sound and music related objects
cocos/math/: math related objects
cocos/platform/: platform specific objects
cocos/renderer/: GPU related objects like Renderer, Texture2D, Render Commands, etc.
cocos/physcis/: physics related objects
cocos/network/: network retlated objects
cocos/editor-support/: 3rd party editors file format
2014-03-07 09:24:55 +08:00
2014-05-20 07:56:33 +08:00
## Particle System fixes
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
cocos2d-x v3.0 and earlier versions had a bug in `ParticleSystem` where the the Y-flipped parameter was not calculated correctly.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
We fixed that bug in v3.1. The problem is that fixing this bug breaks backward compatiblility in particles that were relying on the broken behavior.
2014-01-07 08:23:06 +08:00
2014-05-20 07:56:33 +08:00
In order to try to make the transition easier to v3.1, we created a tool that fixes the broken particle system files. How to use it:
2014-02-26 16:41:47 +08:00
2014-05-20 07:56:33 +08:00
# Will convert broken .plist files into fixed ones.
# Will generate a backup file of the converted files
$ cocos/tools/particle/convert_YCoordFlipped.py *.plist
2014-01-07 08:23:06 +08:00
# Misc API Changes
## deprecated functions and global variables
2014-05-20 07:56:33 +08:00
TODO: The old Math API