Reputation: 2191
I am facing a strange issue with Sprite Kit (on OS X, didn't tried it on iOS) : I create my scene with this code :
SKScene *scene = [MyScene sceneWithSize:CGSizeMake(1280, 800)];
And when I create a node, like this :
SKSpriteNode* ground = [SKSpriteNode spriteNodeWithColor:[NSColor brownColor] size:CGSizeMake(1280, 800)];
What I don't understand is that even if I create my sprite with the same size than my scene, I get this :
As you an see, my sprite, in brown, is two times smaller than my scene (with the blue background).
Do you know why ?
Upvotes: 0
Views: 72
Reputation:
Just add:
ground.anchorPoint = CGPointZero;
or
ground.position = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
The SKSpriteNode
's anchor point is in the center (0.5,0.5) and the default position
is CGPointZero
. So you only see the top right part of your ground.
Upvotes: 3