0

I want to pause my SKScene within my SKScene class. I know the following code works to pause the Scene and the game has already started.

self.scene.view.paused = YES;

But I want to pause my scene AS SOON as my scene starts from WITHIN my class. So what method is best to used for this situation?

-(id)initWithSize:(CGSize)size {    
    if (self = [super initWithSize:size]) {

    self.paused = YES;

}
    return self;

}
4GetFullOf
  • 1,738
  • 4
  • 22
  • 47
  • 1
    Inside your custom SKScene subclass? Simply set self.paused = YES during init. Otherwise I don't understand the question/problem. – CodeSmile Feb 19 '14 at 18:18
  • I do put it within my init and it doesn't work thats why I'm asking the question I post code to show what Ive done – 4GetFullOf Feb 19 '14 at 18:50
  • Ive also tried putting it outside my if statement but still within the init method and still nothing? – 4GetFullOf Feb 19 '14 at 18:52
  • use self.paused in your scene subclass because self.scene will be nil in nodes until the node is added as child to another node (if the parent node is itself already added to the scene graph). Same with self.view. – CodeSmile Feb 19 '14 at 18:55
  • self.paused = YES; still not pausing it for me – 4GetFullOf Feb 19 '14 at 18:58

1 Answers1

6

Move your code to the didMoveToView method:

-(void)didMoveToView:(SKView *)view {
    self.scene.view.paused = YES;
}
Batalia
  • 2,425
  • 1
  • 17
  • 18