0

I have created a SKShapeNode and added it to an SKScene in the following way:

SKShapeNode *newShape = [[SKShapeNode alloc]init];
[newShape setPath:CGPathCreateWithRoundedRect(CGRectMake(0, 0, 120, 120), 8, 8, nil)];
 newShape.strokeColor = newShape.fillColor = [UIColor colorWithRed:66.0f/255.0f
                                                         green:74.0f/255.0f
                                                          blue:84.0f/255.0f
                                                         alpha:1];
 newShape.position = CGPointMake(20, 10);
 [self addChild:newShape];

As both the width and the height of the CGRectMake are the same I would expect to see a square but the SKShapeNode appears to be distorted and it looks about twice as high as it is wide. I'm viewing the scene in portrait mode on my simulator and am wondering if the SKScene is messing or changing the aspect ratio of the shape to account for that. I'm very confused why it's not appearing as a square?

Linda Keating
  • 2,215
  • 7
  • 31
  • 63
  • 1
    What is your `scaleMode` set to? – 0x141E Jan 24 '15 at 02:13
  • I've tried different scaleModes all of them - SKSceneScaleModeAspectFit, SKSceneScaleFill ; SKSceneScaleModeFill; & resize - none works - In Portrait the Height is being set as 768 and the width is being set as 1064 but it should be the other way around. – Linda Keating Jan 24 '15 at 02:29
  • Try `SKSceneScaleModeResizeFill`. – 0x141E Jan 24 '15 at 02:30
  • Oh god - thanks - I just tried it again (I thought I already had?) and it works - thankyou – Linda Keating Jan 24 '15 at 02:32
  • If you are loading your scene from an sis file then the scene size in that file will be used. (.ResizeFill overcomes this though) –  Jan 24 '15 at 10:11

0 Answers0