I'm learning Swift and am getting some weird positioning issues in Sprite Kit with an SKLabelNode.
I wrote the following code:
shareText.position = CGPointMake( self.frame.size.width / 2 , shareButton.position.y );
This does exactly what I expected. It centers the text horizontally on the screen.
Well, I'm splitting my screen in half visually so I'd expect to divide by 4 and have it show up "centered" on the left half of the screen.
shareText.position = CGPointMake( self.frame.size.width / 4 , shareButton.position.y );
Unfortunately it looks as if the SKLabelNode is at the "0" position related to the frame. In fact, based on how much of the text I can see it looks like it's slightly into the negative.
When I check it's position using NSLog, when I divide by 2, it says its x position is 512. When I divide by 4, it says its x position is 256 (what I'd expect) but visually, it's not even close. I've also tried setting it to shareButton.position.x which is also at 256 (and shows visually exactly how I expect it to) but I get the same results. When I manually set it to around 400, it seems to work.
Is there something wrong with Swift (I now it's a beta) or am I doing something wrong?
position
and theanchorPoint
properties. To reply directly to a user, prefix their username with an @ sign in your comment. For example, "@duci9y <your comment>". – duci9y