akuz
akuz

Reputation: 637

SKScene scaleMode not respected on first call to presentScene

I am creating SKView and SKScene programatically in SpriteKit:

        CGRect rect;
        rect.origin.x = 0;
        rect.origin.y = 0;
        rect.size.width = 100;
        rect.size.height = 200;

        SKView* view = [[SKView alloc] initWithFrame:rect];

        view.showsFPS = true;
        view.showsNodeCount = true;
        view.showsDrawCount = true;

        CGSize size;
        size.width = 100;
        size.height = 100;
        SKScene* scene = [[SKScene alloc] initWithSize:size];

        scene.scaleMode = SKSceneScaleModeAspectFit;
        [view presentScene:scene];

The first time the view is displayed, I get an incorrectly scaled scene:

enter image description here

However, if I resize or move the view a little, it becomes scaled correctly:

enter image description here

What am I doing wrong?

EDIT: This only happens on MaxOS (where SKView inherits from NSView), but not on iOS (where SKView inherits from UIView).

Upvotes: 0

Views: 32

Answers (1)

akuz
akuz

Reputation: 637

I found out that there was another MacOS specific resizing of the window going on, which didn't send the resized notification to the views. This is a problem in the framework I am using (JUCE), and not in SpriteKit.

Upvotes: 1

Related Questions