0

I'm using a basic setup with a SKView to display a SKScene. The SKScene has a pre-defined size and uses a scale mode SKSceneScaleModeAspectFit:

- (void)viewDidLoad {
    [super viewDidLoad];
    SKView *skView = (SKView *)self.view;
    SKScene *scene = [MyScene sceneWithSize:CGSizeMake(320, 480)];
    scene.scaleMode = SKSceneScaleModeAspectFit;
    [skView presentScene:scene];
}

As expected, on iPhone 5 this causes letterboxing, i.e. black sections above and under my scene. On iPad, letterboxing causes black stripes to the left and right of the scene.

However, I'd like to position the scene e.g. on iPhone 5 so that the scene is aligned to the bottom of the screen, while all of the black space is positioned above the scene. Is this possible?

I've tried quite a few things with .frame .center .origin, etc. properties of the SKView/SKScene, but can't seem to be able to move the 'display area'. For example, adding

[scene runAction:[SKAction moveTo:CGPointMake(0,-44) duration:0]];

moves the scene's contents inside the display area but not the area itself.

Any ideas?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
MkkLn
  • 23
  • 4
  • One way that works is to use AspectFill as scale mode and adjust position of nodes in the areas that will otherwise not be visible on devices with smaller vertical aspect ration. – CodeSmile Feb 21 '14 at 16:20
  • Thanks for the suggestion @LearnCocos2D. Might have to do a work-around such as that if I cannot adjust the position of the (AspectFit) scene... – MkkLn Feb 21 '14 at 21:27

0 Answers0