Cocos2D-x schedule & scheduleUpdate 的使用

本文介绍了Cocos2D-x中的定时器使用,包括scheduleUpdate方法及其优先级,以及schedule方法的不同形式,如指定执行间隔、重复次数和延迟。同时提到了取消定时器、恢复和暂停定时器的操作。
摘要由CSDN通过智能技术生成


开始学习Cocos2D-x


在cocos2d-x中提供了好几个定时器的方法供调用我们可以在CCNode.h 这个头文件中找到相应的方法,下面整理一下:


(1)使用下面这个方法,那么节点在每一帧都会执行update方法。

/** 
     * Schedules the "update" method. 
     *
     * It will use the order number 0. This method will be called every frame.
     * Scheduled methods with a lower order value will be called before the ones that have a higher order value.
     * Only one "update" method could be scheduled per node.
     */
    void scheduleUpdate(void);


在注释中说到,该方法的order(优先级数)为0,order(优先级数)越小那么越先调度。每一个节点都只能有一个update调度方法。


注意要重写该update方法。

/* 
     * Update method will be called automatically every frame if "scheduleUpdate&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值