Do I really have to reset position and size of SKSpriteNodes with every rotation between landscape and portrait layout??
I've done that and it works .. but this seems to be overkill that the writers of Xcode internally compensated for .. vs. having the individual programmer having to do it.
I have a getGameParms()
which resets positions based on:
#if os(iOS) && !targetEnvironment(macCatalyst)
func getGameParms() {
let roomRect = UIScreen.main.bounds
roomWidth = roomRect.width * roomScale
roomHeight = roomRect.height * roomScale
if (thisSceneName == "GameScene")
{
if UIDevice.current.orientation.isLandscape {
// changes here
}
else {
// changes
}
} // if (thisSceneName == "GameScene")
} // getGameParms
#elseif os(tvOS)
func getGameParms() {
let roomRect = UIScreen.main.bounds
roomWidth = roomRect.width * roomScale
roomHeight = roomRect.height * roomScale
if (thisSceneName == "GameScene")
{
// other changes here
}
} // getGameParms
#endif
Again, the burdensome changes are done .. but are they really necessary?
As an alternative, I have called getGameParms()
just once within my viewDidLoad()
and the results are not correct.
For example, I place one SKSpriteNode
at the very bottom of the UIScreen
and it does not stay there with UIDevice
rotation. I also size it horizontally such that it expands to the full width of the UIScreen
. Rotation destroys that. if getGameParms()
is called only once as just described.
Some explanation as to why would be appreciated.