cocos2dx andriod平台遇到的问题总结

32 篇文章 0 订阅

<pre name="code" class="html"><span style="font-family: 'Trebuchet MS', Verdana, sans-serif;">1. 调用std::sort函数的文件加头文件</span>
 

#include <algorithm>

2. 发现无法访问网络,在 AndroidManifest.xml 中加入以下代码

<uses-permission android:name="android.permission.INTERNET"></uses-permission> 
<uses-permission android:name="android.permission.READ_OWNER_DATA"></uses-permission>

3.使用fopen读取assets里的数据会导致应用crash,因为数据已经被压缩打包进apk文件里了

const char *filepath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszFileName);
unsigned long len = 0; 
pBuffer = CCFileUtils::sharedFileUtils()->getFileData(filepath, "r", &len);

 

4. 自动生成Android.mk的脚本

https://code.csdn.net/snippets/216304

5. 修改应用的名字

./res/values/strings.xml: <string name="app_name">英雄XXX</string>

6. 临时变量的问题

   
   
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std ;
int main ()
{
stringstream s ( "hello stringstream" );
const char * p = s . str (). c_str ();
// s与str的长度是相同的、下面的代码会修改stl库的内存池中得内容
// << efective stl item 15 >> 然而p还指向那个内存中得地址!
string str ( "hello stringeeeeee" );
cout << "p should is \" hello stringstream \" . p is : " << p << endl ;
cout << "s.str().c_str() : " << s . str (). c_str () << endl ;
return 0 ;
}
/* ------程序输出-----------
p should is "hello stringstream". p is : hello stringeeeeee
s.str().c_str() : hello stringstream
*/

通过测试发现用gunstl 就会发生该问题


7.  硬件加速

android:hardwareAccelerated="true"

8.  在CCLabelTTF要换行时总是由一个字没有显示出来,(测试中英文都是一样用的2d-x的版本是2.04)

// org.cocos2dx.lib下的Cocos2dxBitmap.java的代码如下:
while(pString.indexOf(i++) == ' ') {...}
// 修改成:
while(pString.indexOf(i) == ' ') {i++;}

9. android 下的音效文件要用ogg格式


有个命令工具叫
oggenc2.exe

10.只启动一个实例

在androidManifest.xml中设置android:lauchmode="singleTop"
即可,或者在Activity中加入Flag标志位设置intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

11.签名

keytool -genkey -alias android.keystore -keyalg RSA -validity 20000 -keystore android.keystore 


LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

define walk
    $(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e)))
endef


ALLFILES := $(call walk, $(LOCAL_PATH)/../../Classes) 

FILE_LIST := hellocpp/main.cpp
FILE_LIST += $(filter %.cpp, $(ALLFILES))

LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes

# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END


LOCAL_STATIC_LIBRARIES := cocos2dx_static

# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END

include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

cat 1asdf.txt |awk -F\> '{print $2,$1}'|sort -n -r | awk -F" "  '{print $1,$3,$6,$7,$8, $9, $10}'

<pre>

设置提示符 export PS1='\[\033[01;35m\][\u@\h \t] \[\033[0m\]\w \n$'

</pre>

程序布置的路径

/data/data/com.mxhd.rpg

-- cache

-- files

-- lib ->/data/app-lib/com.mxhd.rpg

-- shared_pref 

 cat shared_prefs/*.xml                 

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="user_name">hhl087</string>
<string name="user_password">111111</string>
<boolean name="first5" value="false" />
<int name="last_login_server" value="5" />
<boolean name="server_5_0CBE2150AA2F1AD8D9EADF5CE7FE9E0D_login" value="true" />
<boolean name="starflash" value="true" />
</map>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值