fatal error: use of unimplemented initializer 'init(size:)' for class

前端 未结 2 1555
被撕碎了的回忆
被撕碎了的回忆 2021-01-11 12:19

I was testing my app on different devices and realized the sprite movements were quite inconsistent (running considerably faster on some devices as compared to others). I fo

2条回答
  •  攒了一身酷
    2021-01-11 13:09

    You have asked me to take a look at this question.

    You game does not feel consistent across devices because in your GameViewController you set scene scale mode to .resizeFill. In most cases the default .aspectFill setting is the best option.

    In regards to the error message you need to give the scene a size in the init method when you are not using the xCode level editor e.g

    let scene = GameScene(size: CGSize(width: ..., height: ...))
    

    There is basically 2 options for size

    1) Set the scene size to iPad, which is what I personally do. This is also what Apple uses in DemoBots and what was the default setting in xCode 7. So scene size is either 1024x768 (landscape) or 768x1024 (portrait).

    I design my game area with the iPhone in mind, and simply show some more background, usually ground and sky, on iPads. This is what a lot of popular games I like to play do e.g. Modern Combat 5, Limbo, Altos Adventure, Leos Fortune, The Line Zen, Tower Dash.

    2) Set the scene size to iPhones and show more background on iPhones and less on iPads e.g. Lumino City. So scene size would be what xCode 8 uses, either 1334x750 (landscape) or 750x1334 (portrait).

    This way your game should feel consistent across all devices. The only thing you might have to do is tweak some UI, like button positioning, between iPad and iPhone.

    Hope this helps

提交回复
热议问题