
auto s = Director::getInstance()->getWinSize();
// sun
auto sun = ParticleSun::create();
sun->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
sun->setposition(VisibleRect::righttop().x-32,VisibleRect::righttop().y-32);
sun->setTotalParticles(130);
sun->setlife(0.6f);
this->addChild(sun);
// timers
_label0 = Label::createWithBMFont("Fonts/bitmapFontTest4.fnt","0");
_label1 = Label::createWithBMFont("Fonts/bitmapFontTest4.fnt","0");
_label2 = Label::createWithBMFont("Fonts/bitmapFontTest4.fnt","0");
_label3 = Label::createWithBMFont("Fonts/bitmapFontTest4.fnt","0");
_label4 = Label::createWithBMFont("Fonts/bitmapFontTest4.fnt","0");
scheduleUpdate();
schedule([&](float dt){
_time1 +=dt;
char str[10] = {0};
sprintf(str,"%2.1f",_time1);
_label1->setString( str );
},"step_1");
schedule([&](float dt){
_time2 +=dt;
char str[10] = {0};
sprintf(str,_time2);
_label2->setString( str );
},0.5,"step_2");
schedule([&](float dt){
_time3 +=dt;
char str[10] = {0};
sprintf(str,_time3);
_label3->setString( str );
},1,"step_3");
schedule([&](float dt){
_time4 +=dt;
char str[10] = {0};
sprintf(str,_time4);
_label4->setString( str );
},2,"step_4");
_label0->setposition(s.wIDth*1/6,s.height/2);
_label1->setposition(s.wIDth*2/6,s.height/2);
_label2->setposition(s.wIDth*3/6,s.height/2);
_label3->setposition(s.wIDth*4/6,s.height/2);
_label4->setposition(s.wIDth*5/6,s.height/2);
addChild(_label0);
addChild(_label1);
addChild(_label2);
addChild(_label3);
addChild(_label4);
// Sprite
auto sprite = Sprite::create(s_pathGrossini);
sprite->setposition(VisibleRect::left().x + 40,VisibleRect::bottom().y + 50);
auto jump = JumpBy::create(3,Vec2(s.wIDth-80,0),50,4);
addChild(sprite);
sprite->runAction( RepeatForever::create(Sequence::create(jump,jump->reverse(),nullptr) ));
// pause button
auto item1 = MenuItemFont::create("Pause",[&](Ref* sender) { if(Director::getInstance()->isPaused()) Director::getInstance()->resume(); else Director::getInstance()->pause(); }); auto menu = Menu::create(item1,nullptr); menu->setposition(s.wIDth/2,s.height-50); addChild( menu ); 总结
以上是内存溢出为你收集整理的cocos2dx3.5 interval 中看两个lambda替换menu_selector,schedule_selector全部内容,希望文章能够帮你解决cocos2dx3.5 interval 中看两个lambda替换menu_selector,schedule_selector所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)