I created an SKView that represents a subclass of SKScene as follows:
SKView *skv = [[SKView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:skv]; self.skScene = [[TestScene alloc] initWithSize:v.bounds.size]; [skv presentScene:_skScene];
Then, to see the origin, I add a small 10x10 square to the scene.
SKSpriteNode *ori = [SKSpriteNode spriteNodeWithColor:[UIColor greenColor] size:CGSizeMake(10,10)]; [self addChild:ori];
You can see the green square in the lower left corner:

From what I thought, SpriteKit's coordinate system is such that the origin is always in the center. But on the stage, the source is in the lower left corner. When I add a node child to {0,0}, it also appears in the lower left corner.
When I add SKSpriteNode and position it {0,0} in the scene, it appears in the lower left corner. But it is centered around the beginning of the scene in the lower left corner (cut off from half to the left and half to the bottom).
But now it is becoming more confusing. When I add SKSpriteNode to another SKSpriteNode, the sub-sprite is CENTERED in the parent.
Does this mean that the coordinate system of the scene does not work like the coordinate system of the sprite?
Summary:
- When I place the sprite in the scene at {0,0}, it appears at the bottom left, cropped by 50% (centered around the source).
- When I put a sprite in a sprite at {0,0}, it appears in the center of the sprite.
Is my scene set up incorrectly or is it the way it works?
ios ios7 sprite-kit skspritenode sknode
openfrog
source share