When i need to transfer between my starter scene that does nothing only showing my logo to the main menu scene without touching the screen “automatic” to Main menu scene
Start.h:
#ifndefSTART_SCENE_H #defineSTART_SCENE_H
#include “cocos2d.h”
class StartScene : public cocos2d::Layer
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
// a selector callback
void gotoMainMenuScene();//cocos2d::Ref* pSender
// implement the "static create()" method manually
CREATE_FUNC(StartScene);
Scene* StartScene::createScene()
{
// ‘scene’ is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = StartScene::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 StartScene::init()
{
if ( !Layer::init() )
{
return false;
}
The scheduler allows you to have a function called after a certain amount of time, and do so once, a specified amount of times or forever until you change scene or tell it to stop. I can’t remember the exact way to use it (something like this->scheduleOnce(schedule_selector(HelloWorld::myFunction), but not sure off the top of my head. Look up schedule and scheduleOnce.
Actions usually allow you to manipulate nodes, but you can use them to wait for a certain amount of time and to call functions. Try searching for CallFunc and runAction.