关于cocos2d2.0x2.0.4-x3.0和2.0之间的区别

Cocos2d-x v3.0 Beta and Coordinate Release
Cocos2d-x v3.0 Beta have significant improvements such as new renderer, templated containers, shadow/glow/outline support for label, and more. On the other hand, we have very stable v2.2 coordinate release of Cocos2d-x, CocoStudio, Cocos2d-html5 together.
We are happy to announce the release of:
* Cocos2d-x v3.0-beta
* Coordinate Release:
*** cocos2d-x v2.2.2
*** cocos2d-html5 v2.2.2
*** CocoStudio v1.2
h1. cocos2d-x v3.0 Beta
h3. Download
h3. Highlights
** New renderer. Renderer has being decoupled from the Scene Graph. It supports auto-batching and auto-culling.
* Added template containers. cocos2d::Map&&, cocos2d::Vector&&
* Label supports: shadow, glow and outline (beta)
* Added Joint support in the physics subsystem
* Added Console: A simple TCP console that lets you debug and inspect your game remotely
* tools/project_creator/project_creator.py includes a GUI to simplify the game creation process. It also allows you to create the game in any given directory.
* Added support to build Android’s APK files in the android-build.py script
* Added Scheduler::performFunctionInCocosThread(). It supports executing a function in the cocos2d thread
* Director emits the following events using the EventDispatcher: AFTER_UPDATE, AFTER_DRAW, AFTER_VISIT and PROJECTION_CHANGED
* Added Cocos2dxActivity.java which inherits from native activity. Ingetrating 3rd Android SDK would be much easilier on v3.0.
Read more about all the new features at
Documents for v3.0
Template containers: , . v3.0 uses cocos2d::Map&& instead of CCDictionary, cocos2d::Vector&& instead of CCArray.
wrapping many basic data types such as int,float,double,bool,unsigned char,char* and std::string.
GUI System series: ,
like Layout, ScrollView, PageView, and
including CheckBox, LoadingBar, Slider, Button, TextField etc.
would be helpful to developers using JavaScript bindings on cocos2d-x
Cocos2d-x v2.2.2
Highlights
Added support for CocoStudio v1.2. It includes JS and Lua bindigns for CocoStudio
WinPhone8 & Windows8: added XAML support, updated to latest version of ANGLE
CocoStudio v1.2
Highlights
Added Japanese and Spanish localizations.
Added the function: the scale and the reference line.
Animation Editor
Improved the efficiency after several switching animation lists.
Edit the polygon collision zone : automatic image matching, contour tracing point, since the painting outline, etc.
Added custom easing curve support.
Added UI controls: ListView and PageView.
Added custom easing curve support.
Modified the custom font settings in the text controls.
Scene Editor
Added the Trigger setting.
Added the function: Trigger automatic generate code.
Read more about all the new features at .
Cocos2d-html5 v2.2.2
Highlights
Resolution policy now act as a combination of cc.ContainerStrategy and cc.ContentStrategy. Users can easily customize its behavior.
cc.LabelTTF now supports automatic line break with occidental and Chinese characters.
Added support for cc.ClippingNode in canvas mode.
Improved performance in setPosition and getPosition in cc.Node and cc.Sprite in about 65.
* @cc.Node@'s @setContentSize@ and @setAnchorPoint@ support pasing @x@ and @y@ as arguments. @setAnchorPoint(x,y)@ is 35 faster than setAnchorPoint(Point(x,y))
Added NPM support and adjusted folder structure. It supports modules customization, the packaged mini engine and HelloWorld is just 185KB in single file mode. Please visit
for more details.
Added SpriteFrameCache JSON format support.
Read more about all the new features at .
Can we expect an updated Cocos2d-X 3.0 documentation soon, or just when a final will arrive?
whiteape, I’ve add some documents’ link in this release note. And we’re still adding more docs for v3.0 in these coming months.
Was hoping the label kerning bug would of been fixed in this latest beta release but still not fixed
The rendering documents link is broken
1.Looking forward to the release version! :D
2.Simple HTML tag support.
Internal error on intro new renderer access,site cant view,please fix it:
Will the release version come out before end of April?
Any document related deprecated method. install.sh file missing for mac.
ARC compatible but some function missing……
So, this CocosStudio will be Windows only? Any plans in porting it to OSX?
Cocos2d-html5 v2.2.2 link give me this error
&Error&&Code&AccessDenied&/Code&&Message&Access Denied&/Message&&RequestId&1C6EBD8&/RequestId&&HostId&mwrq+ysR4F8N47AeW2T7ThVgL5K4C0iq6bFzutt6v0rRBj8aHlibqZYe1HBgLmqV&/HostId&&/Error&
@Richard x
We plan to support rich label after 3.0 final version. In this coming version, we want to make to stable, add missing docs and add performance test.
Meir Yanovich
There is a github version here
@ Timothy Zhang
We plan to release it at the end of Feb. 2014.
@Paulo Cesar Ferreira
Cocostudio will support mac and linux too. In fact, it is in progress.
@lino lino, thanks for your report. It has been fixed now.
is there a possible eta for adding the winphone 8 support to the project_creator.py?
thx for the wicked release
The part involving education and learning to remove feudalism and relative involving master and servant. The slaves will get
liberation from their pros when they have education and learning and perhaps they are aware about the life span all-around these.
jadwal bola
berita bola
jadwal liga inggris
klasemen liga inggris
klasemen liga spanyol
jadwal liga spanyol
timnas indonesia
persib bandung
arema cronus
real madrid
inter milan
manchester united
berita arsenal
berita liverpool
hasil liga champion
liga champion
Recommended
Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.Cocos2d-x 3.0final手机游戏开发视频教程2014 -
兄弟连云课堂 - 更接地气的IT技术精讲平台
本套视频教程主要内容主要分为四大部分:第一部分为手机游戏开发基础:
主要介绍C,C++的编程语言语法结构,对于没有编程基础或原来做Java开发的童鞋可以从这部分开始学习。
第二部分主要介绍Cocos2d-x3.0final版的核心技术
包括开发环境的搭建、Director、Node、Scene、Layer、Action、粒子效果、文件保存、内存管理、用户交互、游戏地图、物理引擎等。
对于有C++语言基础的童鞋和Cocos2d-x早期版本开发者可以从这部分学起。
第三部分主要介绍Cocos2d-x3.0final版的高级编程
主要包括Cocos2d-x网络编程,js脚本编程,Lua脚本编程等技术。
第四部分主要介绍Cocos2d-x3.0项目开发
主要介绍不同游戏类型的游戏的开发逻辑和实现方法。
兄弟连Cocos2d-x学习QQ群:加入时请阐明暗号:Cocos2d-x
Cocos2d-x视频课程概述
章节1: Cocos2d-x手机游戏开发C编程基础
5分钟学会C语言程序入口
5分钟学会变量和表达式
5分钟学会字符类型
5分钟学会条件语句
5分钟学会循环
5分钟学会数组处理
5分钟学会字符串处理
5分钟学会函数定义
5分钟学会指针
5分钟学会函数指针
5分钟学会结构体和自定义类型
5分钟学会结构体数组和联合体
C语言综合案例结构体实现链表与NPC管理系统
5分钟学会文件编程
C语言编程总结
章节2: Cocos2d-x手机游戏开发C++编程基础
C++类和对象
C++面向对象编程_方法重载
C++面向对象编程--类的继承&函数覆盖
C++虚函数和抽象类
C++函数模板与操作符重载
C++ 11新特性
章节3: Cocos2d-x3.0 final手机游戏开发核心技术(正在更新)
开发环境搭建与创建HelloWorld工程
引擎架构分析_Application
引擎架构分析_AppDelegate
实现场景切换_Director&Scene
绘图节点解析和锚点_Node
TestCpp源码分析01_项目架构(上)
TestCpp源码分析01_项目架构(下)
TestCpp源码分析02_功能列表
AutoReleasePool内存管理机制解析
集合Vector的使用
Map&Value的使用
处理屏幕触摸和消息分发机制
Node中处理计划任务Schedule
Action和ActionManager解析
贪食蛇游戏案例01_游戏原型设计
贪食蛇游戏案例02_实现UI流程
贪食蛇游戏案例03_对节点进行封装和游戏逻辑
贪食蛇游戏案例04_游戏触摸交互的实现
贪食蛇游戏案例05_游戏逻辑实现
贪食蛇游戏案例06_在游戏中添加音乐和音效
贪食蛇游戏案例-Mac平台移植到Android
章节4: CocoStudio2014视频教程
兄弟连CocoStudio教程01_在windows系统创建CocoStudio项目
兄弟连CocoStudio教程02_Button的使用
兄弟连CocoStudio教程03_CheckBox的使用
兄弟连CocoStudio教程04_Slider的使用
兄弟连CocoStudio教程05_ImageView的使用
兄弟连CocoStudio教程06_LoadingBar的使用
兄弟连CocoStudio教程07_Text的使用
兄弟连CocoStudio教程08_TextField的使用
兄弟连CocoStudio教程09_Layout的使用
兄弟连CocoStudio教程10_Scrollview的使用
兄弟连CocoStudio教程11_Pageview的使用
兄弟连CocoStudio教程12_listview的使用
兄弟连CocoStudio教程13_listview的事件和RichText
兄弟连CocoStudio教程14_Scale9原理
兄弟连CocoStudio教程15_UI编辑器之Button
Cocos2d-x游戏开发
为成长积蓄力量!
(C)Copyright
All Rights Reserved. 京ICP备号cocos2d-x 通过JNI实现c/c++和Android的java层函数互调 | Alex Zhou的BLOG
& cocos2d-x 通过JNI实现c/c++和Android的java层函数互调
本文主要实现两个功能:
(1)通过Android sdk的API得到应用程序的包名(PackageName),然后传递给c++层函数。
(2)通过c++函数调用Android的java层函数,显示一个对话框,点击按钮退出程序。
1. 首先来简单学习一下JNI的相关知识,我中简单实现了怎么在Android Java层调用c++函数。要想使用JNI,必须得包含头文件,android是使用ndk编译c/c++的,这里jni.h文件位于:\android-ndk-r8b\platforms\android-14\arch-arm\usr\include\jni.h,该文件定义了所有和JNI相关的数据类型和接口。下面是相关代码片段:
# include &inttypes.h&
typedef uint8_
/* unsigned 8 bits */
typedef int8_
/* signed 8 bits */
typedef uint16_
/* unsigned 16 bits */
typedef int16_
/* signed 16 bits */
typedef int32_
/* signed 32 bits */
typedef int64_
/* signed 64 bits */
typedef fl
/* 32-bit IEEE 754 */
typedef dou
/* 64-bit IEEE 754 */
typedef unsi
/* unsigned 8 bits */
/* signed 8 bits */
/* unsigned 16 bits */
typedef sh
/* signed 16 bits */
/* signed 32 bits */
/* signed 64 bits */
typedef fl
/* 32-bit IEEE 754 */
typedef dou
/* 64-bit IEEE 754 */
/* "cardinal indices and sizes" */
#ifdef __cplusplus
* Reference types, in C++
class _jobject {};
class _jclass : public _jobject {};
class _jstring : public _jobject {};
class _jarray : public _jobject {};
class _jobjectArray : public _jarray {};
class _jbooleanArray : public _jarray {};
class _jbyteArray : public _jarray {};
class _jcharArray : public _jarray {};
class _jshortArray : public _jarray {};
class _jintArray : public _jarray {};
class _jlongArray : public _jarray {};
class _jfloatArray : public _jarray {};
class _jdoubleArray : public _jarray {};
class _jthrowable : public _jobject {};
typedef _jobject*
typedef _jclass*
typedef _jstring*
typedef _jarray*
typedef _jobjectArray*
typedef _jbooleanArray* jbooleanA
typedef _jbyteArray*
typedef _jcharArray*
typedef _jshortArray*
typedef _jintArray*
typedef _jlongArray*
typedef _jfloatArray*
typedef _jdoubleArray*
typedef _jthrowable*
typedef _jobject*
#else /* not __cplusplus */
* Reference types, in C.
typedef void*
typedef jo
typedef job
typedef jo
typedef jarray
typedef jarray
typedef jarray
typedef jarray
typedef jarray
typedef jarray
typedef jarray
typedef jarray
typedef jarray
typedef jobjec
#endif /* not __cplusplus */
我们经常用到的是JNIEnv*,它是一个c结构体,封装了许多常用的函数,如:
struct _JNIEnv {
/* it does not seem to be entirely opaque */
const struct JNINativeInterface*
#if defined(__cplusplus)
jint GetVersion()
{ return functions-&GetVersion(this); }
jclass DefineClass(const char *name, jobject loader, const jbyte* buf,
jsize bufLen)
{ return functions-&DefineClass(this, name, loader, buf, bufLen); }
jclass FindClass(const char* name)
{ return functions-&FindClass(this, name); }
// 这里省略其他函数...
cocos2d-x引擎对jni的操作进行了封装,提供了一个非常好用的类:JniHelper,定义了一些常用的接口,该文件位于cocos2dx/platform/android/jni目录下。下面看看JniHelper.h源码:
typedef struct JniMethodInfo_
} JniMethodI
class CC_DLL JniHelper
static JavaVM* getJavaVM();
static void setJavaVM(JavaVM *javaVM);
static const char* getExternalAssetPath();
static void setExternalAssetPath(const char* externalAssetPath);
static jclass getClassID(const char *className, JNIEnv *env=0);
static bool getStaticMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode);
static bool getMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode);
static std::string jstring2string(jstring str);
static JavaVM *m_psJavaVM;
static std::string m_externalAssetP
下面来解释JniHelper的两个常用函数:
(1)getStaticMethodInfo
用来判断Java的类静态函数是否存在,并初始化结构体JniMethodInfo,该结构体封装了JNIEnv*和java.lang.Class对象、函数ID。这样就可以使用JNIEnv*调用 CallStaticXXXMethod(jclass clazz, jmethodID methodID, …)和 CallXXXMethod(jobject obj, jmethodID methodID, …)等常用函数(XXX替换为函数返回值类型,如:Void,Int等)。
第一个参数为JniMethodInfo,第二个参数是类的绝对路径,第三个参数是函数名,第四个参数是函数签名(参数和返回类型),示例代码如下:
if(JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showTipDialog", "(Ljava/lang/SLjava/lang/S)V"))
关于类型签名,请对照下图:
(2)getMethodInfo
该函数与getStaticMethodInfo类似,用于Java类的非静态函数。
2. 下面开始实现文章开头所述的两个功能,本文是在demo的基础上添加的。
(1)利用cocos2d-x创建一个Android工程,名为JniTest,包名为com.alexzhou.jni,此时该包下会自动生成一个JniTest.java文件。
(2)首先来实现把应用程序的包名传递给c++函数,在包下创建JniTestHelper.java,该类封装了给c++调用的函数,添加如下代码:
private static Handler mH
public static void init(Handler handler)
JniTestHelper.mHandler =
public static native void setPackageName(String packageName);
(3)打开JniTest.java,在onCreate函数中添加下面的代码:
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
JniTestHelper.init(mHandler);
JniTestHelper.setPackageName(this.getPackageName());
(4)java层的代码已经完成了,下面来编写jni层代码,在/jni/hellocpp/下创建test.h和test.cpp文件,test.h文件暂时不添加任何函数,代码如下:
#ifndef TEST_H
#define TEST_H
#include "cocos2d.h"
#include &jni.h&
#include "platform/android/jni/JniHelper.h"
#include "test.h"
#include "JniTest.h"
#define CLASS_NAME "com/alexzhou/jni/JniTestHelper"
using namespace cocos2d;
extern "C"
void Java_com_alexzhou_jni_JniTestHelper_setPackageName(JNIEnv *env, jobject thiz, jstring packageName)
const char *pkgName = env-&GetStringUTFChars(packageName, NULL);
setPackageName(pkgName);
env-&ReleaseStringUTFChars(packageName, pkgName);
必须加上extern “C”,声明以c语言的方式进行编译,因为c++和c在编译时生成的函数签名不一样,可以在网上查找相关资料,不然运行的时候会出现链接错误。
(5)现在编写c++函数,在Classes目录下创建JniTest.h,代码如下:
#ifndef JNI_TEST_H
#define JNI_TEST_H
#include "cocos2d.h"
using namespace cocos2d;
void setPackageName(const char *packageName)
CCLog("packageName: %s", packageName);
(6)修改jni/Android.mk文件的LOCAL_SRC_FILES值 ,内容如下:
LOCAL_SRC_FILES := hellocpp/main.cpp \
hellocpp/test.cpp
(7)编译运行,因为我是使用cygwin编译的,而且Android项目不在cocos2d-x的根目录下,所以需要修改build_native.sh,修改COCOS2DX_ROOT和NDK_MODULE_PATH的值,把当前cocos2d-x项目的路径添加到NDK_MODULE_PATH,修改后的值:
COCOS2DX_ROOT="/cygdrive/e/cocos2d-x/cocos2d-2.0-x-2.0.4"
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt:${APP_ROOT}"
运行结果:
(8)现在来实现通过c++函数调用java层函数,显示一个对话框。在JniTestHelper.java添加如下代码:
public static native void exitApp();
private static void showTipDialog(final String title, final String text)
Message msg = mHandler.obtainMessage();
msg.what = JniTest.SHOW_DIALOG;
DialogMessage dm = new DialogMessage();
dm.title =
msg.sendToTarget();
(9)创建一个DialogMessage.java,封装dialog要显示的数据。
author:alexzhou
public class DialogMessage {
(10) 修改JniTest.java,添加显示对话框的函数:
public static final int SHOW_DIALOG = 0x0001;
private Handler mHandler = new Handler()
public void handleMessage(Message msg) {
switch(msg.what)
case SHOW_DIALOG:
DialogMessage dm = (DialogMessage)msg.
new AlertDialog.Builder(JniTest.this)
.setTitle(dm.title)
.setMessage(dm.msg).setNegativeButton("cancle", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
JniTestHelper.exitApp();
.create().show();
(11)在test.h和test.cpp中添加显示对话框的接口:
extern "C"
void showTipDialog(const char *title, const char *msg);
extern "C"
void showTipDialog(const char *title, const char *msg)
JniMethodI
if(JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showTipDialog", "(Ljava/lang/SLjava/lang/S)V"))
jstring jTitle = t.env-&NewStringUTF(title);
jstring jMsg = t.env-&NewStringUTF(msg);
t.env-&CallStaticVoidMethod(t.classID, t.methodID, jTitle, jMsg);
t.env-&DeleteLocalRef(jTitle);
t.env-&DeleteLocalRef(jMsg);
void Java_com_alexzhou_jni_JniTestHelper_setPackageName(JNIEnv *env, jobject thiz, jstring packageName)
const char *pkgName = env-&GetStringUTFChars(packageName, NULL);
setPackageName(pkgName);
env-&ReleaseStringUTFChars(packageName, pkgName);
void Java_com_alexzhou_jni_JniTestHelper_exitApp(JNIEnv *env, jobject thiz)
exitApp();
(12) 修改Classes目录下的JniTest.h,添加代码:
void exitApp()
CCDirector::sharedDirector()-&end();
(13)到此为止,所有代码都已经完成了,代码比较简单就不详细解释了,现在编译运行,效果如下:
源码下载地址:
您可能也喜欢:
我也是第一次使用cocos2d_html5,对js和html5也不熟,看引擎自带的例子和引擎源码,边学边做,如果使用过cocos2d-x的话,完成这个游戏还是十分简单的。游戏体...
上一篇已经完成特性99在win32平台下的开发,现在把它移植到android上,首先修改Android.mk文件,内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_...
现在特性99游戏的功能基本完成了,但是游戏没有首页也挺奇怪,所以这篇博客为游戏添加首页,通过首页进入游戏。
首页的元素比较简单,就是一张背景图,一个l...

我要回帖

更多关于 cocos2d 的文章

 

随机推荐