jendan
jendan

Reputation: 281

SpriteKit camera is not centred with aspectFit

My scene is set to be .AspectFit. I have camera node in scene center and it is connected. Everything works fine for iPad landscape, but when I rotate simulator or run in different device then iPad in landscape camera is not centred. Why?

This is for landscape with camera on center: enter image description here

After rotation camera is not centred: enter image description here

Similar issue is for e.g. for landscape iPhone5s: enter image description here

Why is camera shifted with scene setting .AspectFit with other device then iPad in landscape?

You can try out or experiment with this project on bitbucket I made.

EDIT: When I don't use camera, everything is on its place.

Upvotes: 0

Views: 82

Answers (1)

Knight0fDragon
Knight0fDragon

Reputation: 16847

Set the scene anchor point to 0.5, 0.5 to center your camera onto the scene , there is an issue with the view to scene conversion, and will draw in the top left corner instead of the center. (Also, you will notice your hello world is off, this is because it is not accounting for the anchor change)

Perhaps the lack of a camera will make the scene translate where it draws to inside of the black bars, I have no idea.

Upvotes: 1

Related Questions