ITeye博客

cocos2d 中scheduleUpdate和scheduleUpdateWithPriority对比

mmdev · 2012-12-07 00:26 · Markdown

============================================================

博文原创,转载请声明出处

蓝岩--移动互联网老兵

============================================================

cocosd中CCLayer提供schedule方法来进行帧刷新,默认频率为1秒60帧,如下:

init {
  [self schedule:@selector(tick:)];
}
-(void) tick:(ccTime)dt
{
  // update your stuff here
}

同时cocos2d v0.99.还提供了以下两种更有效的方法来刷新帧。

[self scheduleUpdate];  // use priority == 0 ---A
[self scheduleUpdateWithPriority:an_integer]; ----B

然后在cclayer子类中实现update方法。

-(void) update:(ccTime)deltaTime
{
    // Update your stuff here
}

新老方法有什么不同呢?

  1. 新方法提供了优先级可供选择,意味着你可以为n哥update方法排一下先后执行的顺序
  2. 新方法可以节省一些内存,同时每次更新时候更加迅速

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。