使用CSLoader獲取Node後再獲取精靈失敗

2021-07-09 14:17:09 字數 889 閱讀 8563

今天在寫**的時候遇到乙個很鬱悶的問題,用cocostudio做了乙個介面,然後將其載入到程式當中,也成功獲取了node節點下的幾個精靈,但唯獨有乙個精靈獲取後使用失敗,程式中斷,下面**:

auto node = csloader::createnode("cocostudio/scene.csb");

mones = static_cast

(node->getchildbytag(17));

mtwos = static_cast

(node->getchildbytag(16));

mthrees = static_cast

(node->getchildbytag(15));

mfours = static_cast

(node->getchildbytag(14));

mfives = static_cast

(node->getchildbytag(13));

mones->settexture("icon/1.png");

mtwos->settexture("icon/1.png");

mthrees->settexture("icon/1.png");

mfours->settexture("icon/1.png");

mfives->settexture("icon/1.png");

//mfive 這個精靈一直中斷程式。

檢查了很久,真的很鬱悶,明明csb中有13這個邏輯標籤,前面幾個精靈都獲取成功了,就是這個精靈錯誤。中邪了?

haha ,大家猜猜是為什麼。

因為我不小心在csb中新增了兩個邏輯標籤都為 13的精靈,真是粗心啊,系統無法判定你想獲取哪乙個,反正就是崩了,以後設計介面的時候一定要注意啊!

使用ALAssertLibrary獲取系統相簿

使用alassertlibrary必須要開啟系統定位,先判斷是否可以使用 iscanreadalasset yes void assetgroupenumerator alassetsgroup bool alassetsgroup group,bool stop group enumerator ...

使用curl獲取資料

在工作中需要獲取別人提供的介面,於是使用curl來獲得資料,下面是簡單例子 curl curl init 初始化 curl setopt curl curlopt url url 設定訪問位址 curl setopt curl curlopt timeout,3 設定等待時間為3秒 curl set...

使用ResourceBundle獲取配置檔案

以載入連線資料庫驅動為例 jdbc.properties配置檔案放到src資料夾下,內容如下 driverclass com.mysql.jdbc.driver url jdbc mysql localhost 3306 day16 username root password 12s004020 ...