Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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;