This is really basic I’m sure it has to be something that I am missing. I have been searching in the java / c++ code and I have seen that the AppDelegate.cpp it’s the code between loading resources and showing the game.
Also in application.mk
ifeq ($(NDK_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
endif
NDK_DEBUG is always 0 although I’m doing the release in cocos ide but even changing the if to go to the second condition always the only thing i get is a black screen.
So I thought I would put a splash scene in AppDelegate but it did not work. I’m a bit stuck here any help is welcome
Code of splash:
In AppDelegate.cpp:
(…)
director->setAnimationInterval(1.0 / 60);
//SplashScene::scene();
CCScene *pScene = SplashScene::scene();
director->runWithScene(pScene);
ScriptingCore* sc = ScriptingCore::getInstance();
sc->addRegisterCallback(register_all_cocos2dx);
(…)
SplashScene.cpp
#include "SplashScene.h"
#include <iostream>
#include <sstream>
using namespace cocos2d;
using std::ostringstream;
CCScene* SplashScene::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
// 'layer' is an autorelease object
SplashScene *layer = SplashScene::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
//std::cout << "HOLA" << std::endl;
//dbgprint("\nHOLA");
//return nullptr;
}
// on "init" you need to initialize your instance
bool SplashScene::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayerColor::initWithColor(Color4B(255, 0, 0, 255)) )
{
return false;
}
/*CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//CCSprite *splash = CCSprite::create("default_loading.png");
CCSprite *splash = CCSprite::create("default_loading.png",
CCRectMake(0, 0, 720, 960) );
splash->setPosition(winSize.width * 0.5f, winSize.height * 0.5f);
addChild(splash, 10);*/
return true;
}
SplashScene.h
#ifndef SPLASH_SCENE_H
#define SPLASH_SCENE_H
#include “cocos2d.h”
#include “dbgprint.h”
class SplashScene : public cocos2d::CCLayerColor
{
public:
// Method 'init' in cocos2d-x returns bool, instead of 'id' in cocos2d-iphone (an object pointer)
virtual bool init();
// there's no 'id' in cpp, so we recommend to return the class instance pointer
static cocos2d::CCScene* scene();
CREATE_FUNC(SplashScene);
private:
};
#endif // SPLASH_SCENE_H