在正常的obj-c或cocos2d中有沒有在if-else
塊內延遲的方法? 像如何在延遲之前添加延遲
if ([self isValidTileCoord:cTileCoord] && ![self isWallAtTileCoord:cTileCoord])
{
[self addChild:circle0];
//wait two seconds
//perform another task
}
只是一個簡單的滯後兩個任務之間的等待時間,或拖延行動。有沒有簡單的方法來做到這一點?
我想它雖然 –
它沒有多大的差別同樣的方法執行裏面,所以如果你想這樣做的原因的佈局,我能理解,但代碼非常簡單,並且不難遵循。 – Hacker
如果你不喜歡這種拖延行動的方法,試試克里克的答案。如果你這樣做,我會建議查看蘋果關於dispatch_get_current_queue()的文檔:http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/dispatch_get_current_queue.3.html – Hacker