在你的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