eclipse cocos2dx

参考网址 

http://blog.csdn.net/stupidcodegenerator/article/details/8590821

http://www.himigame.com/android-game/725.html

http://blog.sina.com.cn/s/blog_663b47050100hh94.html

http://andilyliao.iteye.com/blog/494255

0.eclipse上编写C++

stringHelloWorld::init() {} //无return程序会崩溃

1.文件

CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("")

CCFileUtils::sharedFileUtils()-> getWritablePath("")

fullPathFromRelativePath android上是读 assets

getWritablePath android上是 /data/data/包名/

 

可能是大多程序的路径

Environment.getExternalStorageDirectory() + "/Android/data/" + pApplicationInfo.packageName + "/files/" + pPath;

 

2.JNI

java返回String类型给C++

 JniMethodInfo minfo

 JniMethodInfo minfo.env  //env JNIEnV 

 (Ljava/lang/String;)Ljava/lang/String;

返回jstring类型必须用jobject obj接受否则不能编译通过

再把jobject转换成jstring jRet = (jstring) obj;

const char* msg3 = (minfo.env)->GetStringUTFChars(jRet, NULL); //jstring转换const char*

 

猜你喜欢

转载自renzhe20092584.iteye.com/blog/1850458