Wednesday, 15 February 2012

cocos2d x - Create Splash screen in cocos 2d-x -



cocos2d x - Create Splash screen in cocos 2d-x -

hello creating game in cocos2d-x , when scheduling event on splash screen run game .it shows compilation error (in expansion of macro 'schedule_selector')

following code this

splash.h

#ifndef splash_h_ #define splash_h_ #include "cocos2d.h" class ccsplashlayer : public cocos2d::cclayer { private : void rungame(); public: static cocos2d::ccscene* createscene(); virtual bool init(); create_func(ccsplashlayer); }; #endif /* splash_h_ */

and splashscene.cpp

#include "splash.h" #include "cocos2d.h" #include "helloworldscene.h" using_ns_cc; bool ccsplashlayer::init() { if (!layer::init()) { homecoming false; } size visiblesize = director::getinstance()->getvisiblesize(); auto sprite = sprite::create("splash.png"); sprite->setscale(director::getinstance()->getcontentscalefactor()); sprite->setposition(vec2(visiblesize.width / 2,visiblesize.height/2)); this->addchild(sprite, 0); //this line cause problem show symbol on line in eclipse this->scheduleonce(schedule_selector(ccsplashlayer::rungame),4.0f); homecoming true; } scene* ccsplashlayer::createscene() { auto scene = ccscene::create(); auto layer = ccsplashlayer::create(); scene->addchild(layer); homecoming scene; } void ccsplashlayer::rungame(){ auto scene = helloworld::createscene(); director::getinstance()->setdepthtest(true); transitionscene *transition = transitionscene::create(0.5f, scene); director::getinstance()->pushscene(transition); }

schedule_selector takes function pointer needs float argument time.

change method ccsplashlayer::rungame() ccsplashlayer::rungame(float dt) in defination , declaration.

also pushing scene on splash scene, not recommended way splash scene. must replace splash scene new scene because never need display splash 1 time again in game unless there specific design requirement of game.

cocos2d-x

No comments:

Post a Comment