2014-06-13 30 views
0

我想暫停場景,我可以用這段代碼暫停它,但當我點擊相同的按鈕時,如何恢復它?如何恢復暫停按鈕 - 雪碧套件

@property (SK_NONATOMIC_IOSONLY, getter = isPaused) BOOL paused; 


-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 

for (UITouch *touch in touches) 
    { 
     SKSpriteNode *pause = (SKSpriteNode*)[self childNodeWithName:@"pause"]; 

     CGPoint location = [touch locationInNode:self]; 

     if([pause containsPoint:location]) 
     { 
      self.scene.view.paused = YES; 
     } 
    } 
} 
+0

你試過可變基於其當前狀態更改暫停財產? –

+0

這會切換它:self.scene.view.paused =!self.scene.view.paused; – LearnCocos2D

回答

1

試試這個:

self.scene.view.paused = !self.scene.view.paused; 
+0

嗨,謝謝你的關注。這確實恢復了現場,但是有一個問題。例如。如果我有一個球跳,當重新開始時,那個球會再次開始移動,但是從一個不同的位置開始移動,而不是從該球暫停的位置開始移動。有任何想法嗎?謝謝 – user3725724

+0

@ user3725724檢查你的代碼,也許有些東西會在暫停時移動球的位置。 – juniperi