0

In the documented SK programming guide by Apple the first displayed scene is "executed" by this code in the ViewController:

- (void)viewWillAppear:(BOOL)animated
{
HelloScene* hello = [[HelloScene alloc] initWithSize:CGSizeMake(768,1024)];
SKView *spriteView = (SKView *) self.view;
[spriteView presentScene: hello];
}

Source: https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/GettingStarted/GettingStarted.html

Notice that it's a sample project for the iPad, so the view size is fixed (768, 1024). How do I set it up, so that it could scale up nicely on an iPhone 4/5 (and probably the next gen iPhone)?

sangony
  • 11,636
  • 4
  • 39
  • 55
user3545063
  • 681
  • 8
  • 17

1 Answers1

1

You could get the device's size and use this, for example:

- (void)viewWillAppear:(BOOL)animated
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGSize screenSize = screenRect.size;
    HelloScene* hello = [[HelloScene alloc] initWithSize:screenSize];
    SKView *spriteView = (SKView *) self.view;
    [spriteView presentScene: hello];
}
lucianomarisi
  • 1,552
  • 11
  • 24