cocos2dxschedule可延时的for循环scheduleonce的问题
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了cocos2dxschedule可延时的for循环scheduleonce的问题,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1132字,纯文字阅读大概需要2分钟。
内容图文
scheduleonce 只执行一次的时间函数,可以看做延迟执行。 今天想用scheduleonce做一个延迟的for循环 大体思路如下: //全局 int i=1; scheduleF(0.5f);//调用 //时间函数 void hello::scheduleF(float f) { if(i10) { …… scheduleonce (schedule_selector(
scheduleonce 只执行一次的时间函数,可以看做延迟执行。
今天想用scheduleonce做一个延迟的for循环
大体思路如下:
//全局
int i=1;
scheduleF(0.5f);//调用
//时间函数
void hello::scheduleF(float f)
{
if(i<10)
{
……
scheduleonce(schedule_selector(hello::scheduleF),0.3f);
}
i++;
}
试了一下,不行,最多执行到i=2,应该是手动调用一次,scheduleonce第一次可以。
所以我觉得可能是scheduleonce已经添加过这个函数了,不能多次添加,于是想在添加之前un一下,但是没找到unscheduleonce这个方法,用了unschedule,测试还是不行。
无奈全部换成了schedule,unschedule
void hello::scheduleF(float f)
{
if(i<10)
{
……
unschedule(schedule_selector(hello::scheduleF));
schedule(schedule_selector(hello::scheduleF),0.3f);
}
else
{
unschedule(schedule_selector(hello::scheduleF));
}
i++;
}
这样就行了,不过遗漏unscheduleonce这个方法,不知是不是漏洞····
内容总结
以上是互联网集市为您收集整理的cocos2dxschedule可延时的for循环scheduleonce的问题全部内容,希望文章能够帮你解决cocos2dxschedule可延时的for循环scheduleonce的问题所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。