eclipse编译c++代码失败
在Application.mk里添加STLPORT_FORCE_REBUILD := true即可。
eclipse提示c++代码错误
Window--Preferences--C/C++--Code Analysis,取消Syntax and Semantic Errors的勾选。
Android.mk修改
FILE_LIST := hellocpp/main.cpp \
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes
文件路径问题
windows下可以直接读取,而android下需要使用CCFileUtils操作。
比如:
//根据xml数据创建动画 string xmlFile_path = "a.xml"; //获得文件在系统的绝对路径 string xmlfilepath = CCFileUtils::sharedFileUtils()->fullPathForFilename(xmlFile_path.c_str()); //读取的字节数,读取失败则为0 unsigned long len = 0; //读取的内容 unsigned char *data =CCFileUtils::sharedFileUtils()->getFileData(xmlfilepath.c_str(),"r",&len);
第一次安装时游戏崩溃
修改Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp里:
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() { // CCApplication::sharedApplication()->applicationDidEnterBackground(); if (CCDirector::sharedDirector()->getOpenGLView()) { CCApplication::sharedApplication()->applicationDidEnterBackground(); } CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND,NULL); }
横竖屏控制
修改AndroidMenifest.xml里的activity部分:
android:screenOrientation="portrait"
屏幕适配
pEGLView->setDesignResolutionSize(w,h,kResolutionShowAll);要放在pDirector->setOpenGLView(pEGLView);之后,否则会出现程序崩溃。