eclipse编译c++代码失败
在Application.mk里添加STLPORT_FORCE_REBUILD := true即可。
@H_301_5@
eclipse提示c++代码错误
Window--Preferences--C/C++--Code Analysis,取消Syntax and Semantic Errors的勾选。
@H_301_5@
Android.mk修改
FILE_LIST := hellocpp/main.cpp \@H_301_5@ FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)@H_301_5@ LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)@H_301_5@ @H_301_5@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes@H_301_5@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes@H_301_5@
@H_301_5@
文件路径问题
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);@H_301_5@ @H_301_5@
@H_301_5@
第一次安装时游戏崩溃
修改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); }@H_301_5@
横竖屏控制
修改AndroidMenifest.xml里的activity部分:
android:screenOrientation="portrait"@H_301_5@
屏幕适配
pEGLView->setDesignResolutionSize(w,h,kResolutionShowAll);要放在pDirector->setOpenGLView(pEGLView);之后,否则会出现程序崩溃。