Search code examples
iosswiftsprite-kitiphone-x

Update function in SpriteKit different for iPhone X


I have a SpriteKit game in Swift. It scrolls along indefinitely in landscape mode spawning obstacles and enemies in the update() function of the scene every so often.

I also update the score value here. The problem is in iPhone X since the length is different it totally messes up the game and makes it unplayable. Things spawn way too fast and the score updates slowly.

To top this off the simulator seems to run the game differently than actual devices, it plays fine on the simulator iPhone X. But, when I looked at it on my friends iPhone X it was impossible, so I’m not even sure if the changes I’m making are going to make a difference!

Please help!


Solution

  • Allowing for different aspect ratios, resolutions, units and distances (in endeavouring to create a consistent game experience across all) is a hard problem made difficult.

    The only way to be absolutely certain is to work in a consistent, arbitrary physics space and resolve resolution and aspect ratios via an abstracted camera that doesn't care about the device's screen/resolution/aspect ratio.

    Even then, you need to prioritise the physics in such a way that variances in frame rendering times (between devices) don't cause any peculiar differences between differing devices.

    But, even then, that's not going to be absolutely perfect. Just close to it.

    And ignore the simulator, always. It's only good for testing where things are, not how they behave, nor even how they look.