I just installed Cocos2d-x on my WIndows 7 OS with Eclipse IDE for Android. But strange things happening. Whatever I change my code in the “HelloWorldScene.cpp” file, everytime I get is HelloWorld Screen which comes up with Cocos2d-x on my Android Device(2.3.6). What I tried to do is to Clean Project,delete app from my Android Device, launch and install again but nothing. I still getting what HelloWorld Screen. This is my “HelloWorldScene.cpp” file:
#include "HelloWorldScene.h"
USING_NS_CC;
CCScene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite *bg = CCSprite::create("moles_bg.png");
bg->setPosition(ccp(size.width/2,size.height/2));
this->addChild(bg,-1);
float rX = size.width / bg->getContentSize().width;
float rY = size.height / bg->getContentSize().height;
bg->setScaleX(rX);
bg->setScaleY(rY);
return true;
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
This is my “AppDelegate.cpp” file:
#include "AppDelegate.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate() {
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// pDirector->enableRetinaDisplay(true);
// turn on display FPS
pDirector->setDisplayStats(false);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
CCDirector::sharedDirector()->stopAnimation();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
CCDirector::sharedDirector()->startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}
All assets is in my “Assets” folder.
This is what my LogCat saying:
09-13 14:59:38.765: D/dalvikvm(12292): Trying to load lib /data/data/com.cococs.andgame/lib/libgame.so 0x40515f88
09-13 14:59:38.789: D/dalvikvm(12292): Added shared lib /data/data/com.cococs.andgame/lib/libgame.so 0x40515f88
09-13 14:59:38.796: I/ApplicationPackageManager(12292): cscCountry is not German : SEB
09-13 14:59:38.843: D/SensorManager(12292): ====>>>>>Num Sensor: 1
09-13 14:59:38.843: D/SensorManager(12292): ====>>>>>Num Sensor: 2
09-13 14:59:38.851: D/SensorManager(12292): ====>>>>>Num Sensor: 3
09-13 14:59:38.851: D/SensorManager(12292): ====>>>>>Num Sensor: 4
09-13 14:59:38.851: D/SensorManager(12292): ====>>>>>Num Sensor: 5
09-13 14:59:38.851: D/SensorManager(12292): ====>>>>>Num Sensor: 6
09-13 14:59:38.851: D/SensorManager(12292): ====>>>>>Num Sensor: 0
09-13 14:59:38.882: I/ApplicationPackageManager(12292): cscCountry is not German : SEB
09-13 14:59:38.882: W/apk path(12292): /data/app/com.cococs.andgame-1.apk
09-13 14:59:39.039: I/GLThread(12292): noticed surfaceView surface lost tid=12
09-13 14:59:39.054: I/GLThread(12292): onResume tid=12
09-13 14:59:39.054: D/cocos2d-x debug info(12292): cocos2d: cocos2d-2.0-rc2-x-2.0.1
09-13 14:59:39.070: D/PhoneWindow(12292): couldn't save which view has focus because the focused view org.cocos2dx.lib.Cocos2dxGLSurfaceView@40524448 has no id.
09-13 14:59:39.093: I/GLThread(12292): onPause tid=12
09-13 14:59:39.093: I/Main thread(12292): onPause waiting for mPaused.
P.S. I’m running it on my real device because Android Emulator just doesn’t work at all. But it’s different talk.
Thanks for any help.
EDIT: My Console window showing me an error like this:
16:08:35 **** Incremental Build of configuration Default for project AndGame ****
cmd {workspace_loc:/com.cococs.andgame}./build_native.sh NDK_DEBUG=1 V=1 all
Cannot run program "cmd": The directory name is invalid.
16:08:35 Build Finished (took 18ms)
I rememeber what I went to my project Properties -> C/C*+ Build -> Unchecked “Use default build command” and write cmd /build_native.sh NDK_DEBUG=1 V=1 . Maybe here is the problem? Maybe I messed up something with this one? I added image how my C/C* Build window.
Untitled.png (90.5 KB)