我使用Cocos2D-x
编写了基本游戏。它在iPhone上运行良好。现在我正在尝试将其移植到Android。当我运行脚本时,它给出了以下错误:
jni/../../Classes/MemoryModeLayer.cpp: In member function 'void MemoryModeLayer::startNewGame()':
jni/../../Classes/MemoryModeLayer.cpp:109:25: error: 'time' is not a member of 'std'
jni/../../Classes/MemoryModeLayer.cpp:109:25: note: suggested alternative:
/Users/abc/android-ndk-r9d/platforms/android-8/arch-arm/usr/include/time.h:40:17: note: 'time'
jni/../../Classes/MemoryModeLayer.cpp:111:5: error: 'random_shuffle' is not a member of 'std'
jni/../../Classes/MemoryModeLayer.cpp:112:5: error: 'random_shuffle' is not a member of 'std'
make: *** [obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/MemoryModeLayer.o] Error 1
make: Leaving directory `/Users/anil/cocos2d-x-2.2.3/projects/Game/proj.android'
在MemoryModeLayer.cpp中我有以下内容:
std::srand(unsigned(std::time(0)));
std::random_shuffle(_xCod, _xCod + _numberOfRows);
std::random_shuffle(_yCod, _yCod + _numberOfColumns);
我还包括以下标题:
#include <string>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <iomanip>
还在头文件中添加了using namespace std
。还有什么我应该做的吗?
答案 0 :(得分:0)
您需要#include <random>
答案 1 :(得分:0)
Application.mk文件存在问题。不得不像这样更改STL库查找:
将APP_STL := stlport_static
添加到Application.mk文件中。它可能已经有APP_STL := gnustl_static
。
以下博客文章非常有帮助!
http://blog.codetactics.com/2013/06/05/porting-a-cocos2d-x-ios-game-to-android/