android 消滅星星出錯

2021-06-30 16:19:44 字數 1421 閱讀 2177

今天看了下

今天在執行消滅星星時,在win32上沒問題,但是在android平台下,總是出現下面

這個錯誤:

04-10 18:11:40.926: d/dalvikvm(18100): trying to load lib /data/data/com.smart.star/lib/libcocos2dcpp.so 0x3195d750

04-10 18:11:40.926: d/cocos2d-x debug info(18100): cocos2d: fullpathforfilename: no file found at chinesewords.xml. possible missing file.

04-10 18:11:40.946: a/libc(18100): fatal signal 11 (sigsegv) at 0x00000000 (code=1)

**如下:

#ifndef _chineseword_h_

#define _chineseword_h_

#include #include using namespace std;

using namespace cocos2d;

static valuevector txt_vec = fileutils::getinstance()->getvaluevectorfromfile("chinesewords.xml");

static string file = fileutils::getinstance()->fullpathforfilename("menu_start.png");

string chineseword(const char* wordid);

#endif

我做了一下測試:

1、修改chinesewords.xml名字,不行。

2、在資源檔案目錄下找一張,如menu_start.png,然後放在同樣的位置

使用fileutils::getinstance()->fullpathforfilename("menu_start.png");這個函式,同樣報錯。

從這裡應該就能看出,static valuevector txt_vec = fileutils::getinstance()->getvaluevectorfromfile("chinesewords.xml");

上面的**放在這裡執行在android下不可以。

解決:

我們定義乙個全域性的valuevector txt_vec變數,不在這裡初始化,而放在gamelayer.cpp的init函式中

呼叫txt_vec = fileutils::getinstance()->getvaluevectorfromfile("chinesewords.xml");,問題就解決了。

消滅星星c語言

只寫好了遞迴,消除,看見這個標題是不是很刺激啊 願賭服輸 這個是我18年寫的,我最近寫了掃雷,無意中也寫完了。這裡寫 include includestruct star static int score 0 static int count static int count1 static int...

使用C語言 EasyX完成消滅星星遊戲(2)

include include include include include pragma comment lib,winmm.lib pragma warning disable 4996 define n 40 image bgimage 遊戲頁面背景 image regbgimage 註冊頁...

Android星星評分控制項RatingBar的使用

在android的開發中,有乙個叫做評分控制項ratingbar,我們可以使用該控制項做等級劃分 評分等作用,星星形狀顯示,也可以半星級別,我們來看一下評分控制項如何使用。布局檔案中定義控制項以及屬性,這裡主要需要指定的是總星星數量,和當前的值,也就是總級別跟當前級別的量。評分控制項中兩個比較重要的...