我没有使用Sprite Kit的经验.我想知道Sprite Kit中有类似Cocos2D 调度程序的东西吗?如果不是,应该使用什么NSTimer是唯一的选择?我想如果唯一的选择是使用 NSTimer我们手动需要处理应用程序在后台的情况.谢谢.
Dob*_*pir 21
要实现类似于cocos调度程序的功能,您可以使用SKAction.
例如,为了达到这样的目的
[self schedule:@selector(fireMethod:) interval:0.5];
Run Code Online (Sandbox Code Playgroud)
使用SKAction你会写这个
SKAction *wait = [SKAction waitForDuration:0.5];
SKAction *performSelector = [SKAction performSelector:@selector(fireMethod:) onTarget:self];
SKAction *sequence = [SKAction sequence:@[performSelector, wait]];
SKAction *repeat = [SKAction repeatActionForever:sequence];
[self runAction:repeat];
Run Code Online (Sandbox Code Playgroud)
它不是最好看的,并且缺乏CCScheduler的一些灵活性,但它会暂停背景,暂停场景/视图等+它就像玩乐高积木:)
| 归档时间: |
|
| 查看次数: |
3929 次 |
| 最近记录: |