Pop Flamingo
Pop Flamingo

Reputation: 2191

Strange size in Sprite Kit

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 : enter image description here

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

Answers (1)

user867635
user867635

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

Related Questions