0

I'm working on an objective C SpriteKit Mac app that's targeting 10.11. I'm creating an SKScene without using an SKS since all of the items in my app are dynamically generated. The size of the window for my app is coming out as 800x600, but I want to change that. From what I've seen in the SKView class API, there's no way to resize the view. Any ideas?

Here's the code I have right now in my ViewController.m class:

#import "ViewController.h"
#import "TitleScene.h"

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    TitleScene *scene = [TitleScene sceneWithSize:CGSizeMake(1920, 1080)];

    // Set the scale mode to scale to fit the window
    scene.scaleMode = SKSceneScaleModeAspectFill;

    self.skView.showsFPS = YES;
    self.skView.showsNodeCount = YES;
    self.skView.ignoresSiblingOrder = YES;


    // Present the scene
    [self.skView presentScene:scene];
}

@end
02fentym
  • 1,762
  • 2
  • 16
  • 29
  • i had the same problem, i've changed the sizes like this: `let screenBounds = UIScreen.main.bounds self.xViewScale = 800 * 2 / screenBounds.width self.yViewScale = 480 * 2 / screenBounds.height` and then wherever i had sizes, multiplying them to these custom sizes like this: `myNode.position = CGPoint(x: targetNode.x! * xViewScale , y: targetNode.y! * yViewScale )` – Mina Dec 18 '16 at 05:29
  • 1
    You can change the view and window sizes in the storyboard – 0x141E Dec 18 '16 at 07:33
  • Wow, I never even thought about checking the main storyboard :/ Aside from changing it that way, is there any way to do it programmatically? For example, let's say I want to be able to control the size of the window within the app's settings...that would be a reason for doing it programmatically. – 02fentym Dec 18 '16 at 07:38
  • 1
    You can set the `frame` property of the view and window. – 0x141E Dec 18 '16 at 18:35
  • Thanks. I think I misread your answer before. I got it...thanks a bunch. For those who might come across this issue in the future, this one-liner fixed it for me: `[self.skView setFrame:NSMakeRect(self.skView.frame.size.width/2, self.skView.frame.size.height/2, 1920, 1080)];` – 02fentym Dec 19 '16 at 05:31

0 Answers0