2014-03-31 1 views

답변

1

SKActions로이 작업을 수행 할 수 있습니다. 예를 들어 ...

SKAction *wait = [SKAction waitForDuration:1.0f]; 
SKAction *sequence = [SKAction sequence:@[[SKAction performSelector:@selector(methodToFire:) onTarget:self], wait]]; 
SKAction *repeat = [SKAction repeatActionForever:sequence]; 
[self runAction:repeat]; 


- (void)methodToFire { 
... 
} 
2

당신이 뭔가 게임 로직이 관련 할 싶은 경우,이 장비 당신이 원하는 것을 할 수있는 업데이트 방법에 꽤 간단합니다.

-(void)update:(CFTimeInterval)currentTime 
{ 
    /* Called before each frame is rendered */ 
    // Handle time delta. 
    // If we drop below 60fps, we still want things to happen at the same realtime rate. 

    CFTimeInterval timeSinceLast = currentTime - lastUpdateTimeInterval; 
    lastUpdateTimeInterval = currentTime; 

    [self updateWithTimeSinceLastUpdate:timeSinceLast]; 

} 

- (void)updateWithTimeSinceLastUpdate:(CFTimeInterval)timeSinceLast 
{ 

    lastEventInterval += timeSinceLast; 
    //this is the part that will function like a timer selector and run once a second. 
    if (lastEventInterval > 1) 
    { 
     lastEventInterval = 0; 
     //do whatever you want to do once a second here 
    } 
} 
+0

NSTimeInterval 대신 CFTimeInterval을 사용하는 이유는 무엇입니까? – Roecrew

+0

업데이트 방법으로 전달되는 매개 변수에 사과가 사용되었으므로 그 안에 사용 된 내용입니다. 비슷한 문제가없는 NSTimeIntervals도 사용했습니다. 나는 둘 사이의 차이점에 대해서는 분명히 명확하지 않습니다 - 둘 다 typedef'd 복식 인 것처럼 보입니다. – webbcode

관련 문제