在普通的obj-c或cocos2d中,有没有一种方法可以在if-else块中进行延迟?喜欢
if ([self isValidTileCoord:cTileCoord] && ![self isWallAtTileCoord:cTileCoord])
{
[self addChild:circle0];
//wait two seconds
//perform another task
}只是在两个任务之间等待的一个简单的延迟,或者拖延一个动作。有什么简单的方法可以做到这一点吗?
发布于 2013-05-19 07:49:59
有很多方法可以做到这一点。我会使用GCD
if ([self isValidTileCoord:cTileCoord] && ![self isWallAtTileCoord:cTileCoord])
{
[self addChild:circle0];
//wait two seconds
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
//perform another task;
});
}https://stackoverflow.com/questions/16630009
复制相似问题