`
浮生长恨
  • 浏览: 208618 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

cocos2d中的schedule使用-转

阅读更多
cocos2d中的schedule有两种作用

1)定时执行方法,例如每隔3秒钟执行一次方法fire

看例子:

- (id) init{
    if((self = [super init])){
       [game addChild:self]
       [self schedule:@selector(fire) interval:3];
    }
    return self;
}

- (void) fire{
    NSLog(@"fire");
}


2)延时执行方法,例如5秒种后执行方法destory

看例子:

- (id) init{
    if((self = [super init])){
       [game addChild:self]
       [self schedule:@selector(destory) interval:5];
    }
    return self;
}

- (void) destory{
    NSLog(@"destory");
    [self unschedule:@selector(destory)];
    [self.parent removeChild:self cleanup:YES];
}
分享到:
评论

相关推荐

    Cocos2D-X开发学习笔记-时间调度schedule函数的使用

    Cocos2D-X开发学习笔记-时间调度schedule函数的使用 教程地址:http://blog.csdn.net/yangyu20121224/article/details/9749457

    cocos2d-x学习笔记(13)--schedule .rar

    cocos2d-x学习笔记(13)--schedule .rar

    Cocos2d-x Schedule定时器的使用实例

    主要介绍了Cocos2d-x Schedule定时器的使用实例,本文的讲解内容包含在代码注释中,需要的朋友可以参考下

    cocos2d-x 自学文档

    一、运动中的加速度 二、拖动间隐效果(比如子弹的运动轨迹) 三、图形绘制 ...cocos2d-x中的CCArray使用注意 十一、屏幕旋转,schedule 和系统语言(后面再看) 十二、音乐音效 十三、CCRenderTexture

    cocos-lua:cocos-lua基于lua gc管理c ++对象的生命周期,并支持更多的cocos2dx v4 API

    科科斯卢阿 cocos-lua以cocos2d-x v4的c ++项目为基础,采用基于lua gc来管理c ++对象的生命周期,提供更丰富的cocos2d-x lua api,包括几乎除模版以外的所有lambda(schedule,scheduleOnce ... )函数变量,能够极...

    cocos2d-xna 写的一个小游戏demo坦克大战

    最近看到网上介绍cocos2d的资料很多,看了看cocos2d也支持wp7,下载了个 Cocos2d-XNA 安装包,写个小例子玩玩,熟悉下cocos2d 程序很简单,就一个入门级的小游戏,写完后放手机里运行了下效果还可以 开发环境 vs2010,...

    Cocos Creator模拟射箭效果shoot.zip

    // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html // Learn Attribute: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - ...

    10_Schedule:cocos2d android开发实践

    10_Schedule practice for android cocos2d The code project is base on Android Studio mac version to write. You can download Android Studio here ( ), and clone the code to run. The guide is here.千锋...

    cocos2dx 雷电MoonWarriors_游戏源码

    using namespace cocos2d; using namespace CocosDenshion; bool isPaused = false; GameLayer::GameLayer():m_state(statePlaying),m_time(0),m_ship(NULL),m_backSky(NULL),m_backSkyHeight(0),m_backSkyRe...

    Creator打地鼠游戏hitmouse.zip

    // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html // Learn Attribute: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - ...

    html5 小游戏 demo

    html5 挺火,写个html5游戏玩玩吧,想起cocos2d 貌似各个平台都有,网上找了找,下载了个Cocos2d-html5引擎包。 貌似另一个开源引擎lufylegend.js也很好,下次用用lufylegend.js试试。 开发环境 chrome Cocos2d-...

    时间调度schedule 1

    2. Schedule函数 带时间参数的,间隔指定时间,然后执行指定的函数,达到定时刷新的效果 1.停止scheduleUpdate()关联的update()函

    Creator数钱小游戏源码CountMoney.zip

    // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html // Learn Attribute: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - ...

    cocos2dx骨骼动画Armature源码剖析(一)

    cocos2dx从编辑器(cocostudio或flash插件dragonBones)得到xml或json数据,调用类似如下所示代码就可以展示出动画效果 ArmatureDataManager::getInstance()->addArmatureFileInfoAsync( "armature/Dragon.png", ...

    C++基础入门教程(九):函数指针之回调

    比如Cocos2d-x的定时器(schedule)、消息订阅(NotificationCenter)都使用了函数指针来完成回调的功能。 这也是为什么我们总是能把某个函数作为参数传进去,然后在某个时刻这个函数会被调用。 一、函数的地址 要...

Global site tag (gtag.js) - Google Analytics