Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Game with Sprite Kit Game Loop and Texture Atlas Transitioning between Scenes

Victor Fernandes
Victor Fernandes
2,869 Points

I am simulating on a iPhone 5s and i can't seem to get the background to fill the screen

what can i do?

Victor, can you post a screenshot of what it the background looks line?

3 Answers

Victor, from the screenshot it looks like you are simulating an iPhone 6 instead of an iPhone 5s. As the screen sizes are different, I believe this is why the background will not fill the screen.

As Florin Veja already stated the issue is that you are simulating on iPhone 6, I myself have the iPhone 6+ and it looked even worse as the background image was even smaller. You need to resize the node to fill the screen.

This is what I did to fix my issue, same as yours.

- (instancetype)initWithSize:(CGSize)size
    self = [super initWithSize:size];

        // Create a background node with image
        SKSpriteNode *background = [SKSpriteNode spriteNodeWithImageNamed:@"splash_1"];
        // Position the node in the middle of the scrren
        background.position = CGPointMake(self.size.width / 2, self.size.height / 2);

        // Stretches the size to fit the screen size of the phone
        // NOTE: For future provide a @3 image for iPhone 6+
        background.size = CGSizeMake(self.size.width, self.size.height);

        // Add background to the main scene
        [self addChild:background];

    return self;