I am having trouble fully grasping the coordinate system with SpriteKit using Swift. I have looked at many resources including apples dev docs but for some reason I am very confused (i'm sure this must be simple).
I have a GameScene class inheriting from SKScene. I am just trying to add a SKSpriteNode to the screen using various coordinates to get used to the screen layout. I believe that when you create any SKNode and give it a position by doing the following
var node = SKSpriteNode(color: UIColor.brownColor(), size: CGSizeMake(100, 100))
node.position = CGPointMake(0, 0)
and then place any SKNode using
self.addChild(node)
The coordinates that have been supplied to the node are coordinates in the parent node. Does this mean that the brown square that has been created should be placed at the bottom left corner?
This is obviously not the case and is what is confusing me. I am using the iPhone 5s simulator for testing in portrait.
The sprite node only appears in the bottom left when I set the position to (350, 50).
Select the GameScene.sks
in the Project Navigator, select the SKScene
(it should have a yellow border round it) and set its size property to 320 points x 569 points (this is assuming iPhone5 / 5S) either way this is the problem. Also make sure you double check it as I am sure it changed back to 1024x768 on me, but seems to be working now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With