0

I would like to create a new scene so that I can embed a UI element in it (a picker view) but I do not want the scene to take up the entire screen, but rather be smaller. I used the following code:

- (void)switchToPickerScene
{
    // Present the new picker scene:
    self.paused = YES;
    CGSize pickerSceneSize = CGSizeMake(300, 440);
    BBPickerScene *pickerScene = [BBPickerScene sceneWithSize:pickerSceneSize];
    pickerScene.scaleMode = SKSceneScaleModeFill;
    SKTransition *trans = [SKTransition doorsOpenHorizontalWithDuration:0.5];
    [self.scene.view presentScene:pickerScene transition:trans];
}

But no matter which SKSceneScaleMode I choose it always fills the entire phone screen. Is there any way to do this?

zeeple
  • 5,509
  • 12
  • 43
  • 71
  • Did you pass your desired size in -(id)initWithSize:(CGSize)size when initializing your scene? – sangony Apr 17 '14 at 04:00
  • 4
    It's not the scene that defines the size, it's the SKView. Either adjust the view's size in Interface Builder or manually create the view with initWithFrame: – CodeSmile Apr 17 '14 at 07:16
  • @sangony Yes, I did, with the following lines: CGSize pickerSceneSize = CGSizeMake(300, 440); BBPickerScene *pickerScene = [BBPickerScene sceneWithSize:pickerSceneSize]; – zeeple Apr 18 '14 at 16:32
  • @LearnCocos2D I guess I don't get that. If the the parent view determines the size of the scene then why does SKScene have an initWithSize? To me that implies that the scene can be any size you pass to it, regardless of the parent view. Also: If a game has multiple scenes, does this mean they all have to be the same size? Afterall, they all start with the same parent view, right? – zeeple Apr 18 '14 at 16:40
  • The scene's size together with its scaleMode determines how the scene stretches its content over the view's size. Normally, and you'll find this in almost every example, the scene's size simply matches the view's size so that there is no stretching. However you may want to use that to more easily adapt your game to a different screen resolution, like iphone vs iphone widescreen vs ipad vs the future iphone 6. You can have multiple scenes each with its own size, for example to stretch menu screens while showing a larger area of the game world on iPad devices during gameplay. – CodeSmile Apr 18 '14 at 19:00

0 Answers0