在你的init
[self scheduleUpdate];
在更新调用不同的选择,当时间条件满足。为了创建时间条件,我们将需要一些全局变量。
ccTime addMonsterAfterDuration = 1;
ccTime addMonsterDurationDecrementValue = 0.1;
ccTime timeSpentSinceLastMonsterAdded = 0;
ccTime addMonsterMinDuration =0.2;
-(void) update:(ccTime)delta{
timeSpentSinceLastMonsterAdded += delta;
if(timeSpentSinceLastMonsterAdded == addMonsterAfterDuration){
[self addMonster];
timeSpentSinceLastMonsterAdded = 0;
addMonsterAfterDuration -= addMonsterDurationDecrementValue;
if(addMonsterAfterDuration < addMonsterMinDuration){
addMonsterAfterDuration = addMonsterMinDuration;
}
}
}
上面的例子仅用于addMonsters。我相信你可以为游戏中的其他物体做同样的事情。
你是什么意思,推迟日程安排?你正在寻找一种方法来减少怪物的时间间隔吗? –
是的,但在某个时间 – Crazycriss