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

iOS Simulator Coordinates Seam Broken

Hey guys,

So, I've been working through the iOS game course, and I've noticed something really weird with my iOS simulator. My simulator looks like it's zoomed in, but I can't figure out how to un-zoom everything. I've tried window > scale. I've tried iOS simulator > reset content and setting. I've tried using the zoom gesture. The problem isn't that the simulator window itself is too small, it's that the content on the screen is getting cropped.

I first noticed when I started creating SKSprite nodes, I set the coordinates to 10, 10, and I couldn't see anything on the screen. Playing around with it I found I had to adjust my coordinates about 100 to compensate for the issue. This is alright, I guess, while I'm learning, but I really don't want to put too much time into something that I know is going to have all the wrong coordinate (having to adjust for my simulator).

I couldn't find anything on Google about this. I'm thinking it's something simple, but I just can't figure it out.

The following code gives me two nodes, both positioned in the bottom left-hand corner. Not sure what I'm missing...

XCode 6.1 OSX 10.10 Obj - C iOS Sim 8.1 - Landscape

    SKSpriteNode *red = [SKSpriteNode spriteNodeWithColor:[SKColor redColor] size:CGSizeMake(50, 200)];
    red.anchorPoint = CGPointMake(0, 0);
    red.position = CGPointMake(10,100);
    [self addChild:red];

    SKSpriteNode *green = [SKSpriteNode spriteNodeWithColor:[SKColor greenColor] size:CGSizeMake(200, 40)];
    green.anchorPoint = CGPointMake(0, 0);
    green.position = CGPointMake(10,100);

    [self addChild:green];

Screenshot http://www.michaelkpeterman.com/wp-content/uploads/2014/11/Screen-Shot-2014-11-28-at-4.50.48-PM.png

1 Answer

I have two different approaches you can use.

Try this first and tell me what happens.

on your SKSpriteNodes that you created, try accessing the xScale and yScale properties.

the values that you set the the scaling properties to can be any real number 0 and greater.

Although .5 scales your image down 50% as opposed to a number like 2 which will double its size.

Here's an example: red.xScale = .5 (or 50%)