bool HelloWorld::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayer::init());
//schedule传入一个参数的时候每一帧都会调用show函数
//this->schedule(schedule_selector(HelloWorld::show));
//以下的schedule方法中,传入的第二个参数是时间,代表多长时间调用一次show函数
//this->schedule(schedule_selector(HelloWorld::show),1.0);
//schedule方法中的前俩个参数和上边的相同,第三个参数是方法调用的重复次数,重复俩次加刚开始的一次
//总共调用了三次,3.0代表执行下边的语句后多长时间开始调用函数show,就是delay的时间
//this->schedule(schedule_selector(HelloWorld::show),1.0,2,3.0);
//scheduleUpdate每隔一帧都会调用update方法,需要我们声明一下update方法
this->scheduleUpdate();
bRet = true;
} while (0);
return bRet;
}
void HelloWorld::update(float dt)
{
static int i = 0;
if(i == 100)
{
//下次不再调用update方法,但是CCLog函数还是会执行的。
//this->unscheduleUpdate();
//以下函数实现相同的功能,它会将这个层的所以schedule方法都停止调用
this->unscheduleAllSelectors();
}
CCLog("i = %d",++i);
}
//show函数必须含有一个float类型的参数
void HelloWorld::show(float dt)
{
static int i = 0;
CCLog("time = %d",++i);
if(i == 10)
{
//unschedule停止传入的参数代表的方法调用
//以下代码不一定需要写在这个show方法中
this->unschedule(schedule_selector(HelloWorld::show));
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有