【cocos2dx】如何实现场景的跳转
发布时间:2020-12-14 19:55:16 所属栏目:百科 来源:网络整理
导读:前面定义了一个SpalshScene.h,并声明了如下的函数,在SplashScene.cpp中对这些函数实现, 跳转用到了CCNode类的定时器有关的函数,详细参考书,这里采用的函数为: void scheduleOnce(SEL_SCHEDULE selector,float delay)// 启动一次定时器,参数为回调函数
前面定义了一个SpalshScene.h,并声明了如下的函数,在SplashScene.cpp中对这些函数实现, 跳转用到了CCNode类的定时器有关的函数,详细参考书,这里采用的函数为: void scheduleOnce(SEL_SCHEDULE selector,float delay)// 启动一次定时器,参数为回调函数及延时启动时间 #include "SplashScene.h" bool Splash::init(){ if (!Layer::init()){ return false; } // show game name auto labelGame = Label::createWithBMFont("futura-48.fnt","2048"); labelGame->setPosition(Point(GAME_SCREEN_WIDTH/2,GAME_SCREEN_HEIGHT/2)); this->addChild(labelGame); labelGame->setScale(1.5); //show game studio auto labelGameVec = Label::createWithBMFont("futura-48.fnt","ml_studio"); labelGameVec->setPosition(Point(GAME_SCREEN_WIDTH / 2,GAME_SCREEN_HEIGHT / 4)); this->addChild(labelGameVec); labelGameVec->setScale(0.8); //计划任务。3秒钟之后自动跳转到游戏场景。 this->scheduleOnce(schedule_selector(Splash::jumpToGame),1);// wait one second // jumpToGame(float) 在下面定义了 return true; } Scene * Splash::createScene(){ auto scene = Scene::create(); auto layer = Splash::create(); scene->addChild(layer); return scene; } void Splash::jumpToGame(float t)//回调函数在这里 { auto scene = Game::createScene(); // Game is another Layer in 'GameScene.h' Director::getInstance()->replaceScene(TransitionProgressOutIn::create(0.5,scene)); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Travis-ci matplotlib依赖和python3
- 自定义Notification
- c# – 如何使用Roles或Composition在NHibernate中映射类
- 2013 duilib入门简明教程 -- XML基础类(7)
- xml解析错误容错
- 晨曦之光 postgreSql基础命令及linux下postgreSql命令
- ruby-on-rails-4 – 使用Minitest测试辅助方法
- c# – 如何检查控制器上下文是否是ASP.NET Core MVC中的子操
- ios – didFinishProcessingPhotoSampleBuffer没有调用
- postgresql – 多列索引和性能