Establecer un tamaño universal para una escena en Sprite Kit

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];
}

Fuente: 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)?

preguntado el 28 de mayo de 14 a las 14:05

1 Respuestas

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];
}

contestado el 28 de mayo de 14 a las 14:05

thanks for your help but everything in my app is out of scale now..(even though i didn't set the size of the buttons to a specific pixel size) why is that? - user3545063

Can you define "out of scale"? Not to state the obvious but consider that for a bigger screen size you'll need to make your images bigger, in points I mean. - lucianomarisi

Nvm I found my problem! - user3545063

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.