像其它的游戏引擎一样,我们有两个不同的方法来完成draw和update。
-(id) init
{
// -10代表优先级,越小则优先级越高,也就越先被执行
[self scheduleUpdateWithPriori ty:-10];
}
-(void) update:(ccTime)deltaTime
{
// update your node here
// DON'T draw it, JUST update it.
// example:
rotation_ = value * deltaTime;
}
调用了scheduleUpdate或者scheduleUpdateWithPriori
[node unscheduleUpdate];
-(id) init
{
// the "step:" selector will be called every 0.5 seconds
[self schedule:@selector(step:) interval:0.5f]
}
-(void) step:(ccTime) deltaTime
{
// update your stuff here
}
注销掉该方法:
[node unscheduleSelector:@selector(step:)];