Issue porting Cocos2d-x to Android

Posted by Anil on Game Development See other posts from Game Development or by Anil
Published on 2014-05-30T07:41:53Z Indexed on 2014/05/30 9:39 UTC
Read the original article Hit count: 389

Filed under:
|
|

I've written a basic game using Cocos2D-x on XCode. It works fine on the iPhone. Now I'm trying to port it to Android. When I run the script ./build_native.sh inside the proj.android folder, it gives me the following error:

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/abc/cocos2d-x-2.2.3/projects/Game/proj.android'

In MemoryModeLayer.cpp I have the following:

std::srand(unsigned(std::time(0)));
std::random_shuffle(_xCod, _xCod + _numberOfRows);
std::random_shuffle(_yCod, _yCod + _numberOfColumns);

I've included the following headers as well:

#include <string>
#include <ctime>
#include <algorithm> 
#include <iostream>
#include <iomanip>

Also added using namespace std in the header file. Is there anything else that I should do?

© Game Development or respective owner

Related posts about c++

Related posts about android