Spritekit将游戏扩展到iPad [英] Spritekit scale full game to iPad

查看:137
本文介绍了Spritekit将游戏扩展到iPad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在使用Spritekit为iPhone开发Xcode游戏。通过使用node.setScale()方法,它在所有iPhone设备上看起来都很相似。现在我想在iPad上制作通用和可运行的。我怎么这么容易做到?是否有一些比例公式?

So I'm developing a game on Xcode using Spritekit, for the iPhone. And it looks all the same and great on all iPhone devices, by using the node.setScale() method. Now I want to make it Universal and runnable on the iPad as well. How do I do this easily? Is there some formula for the scale?

我已经尝试过的是:

if UIDevice.current.userInterfaceIdiom == .pad {
        sscale = frame.size.height / 768
    }else{
        sscale = frame.size.height / 320
    }

然后为每个节点创建node.setScale(sscale)。

And then for every node I make node.setScale(sscale).

这最终无法正常工作,因为在iPad Mini上它看起来与iPad Air不同......即节点大小和位置......

This ends up not working because on the iPad Mini it looks different from the iPad Air... i.e node sizes and positions...

任何帮助?

推荐答案

您基本上有2个选项。

You basically have 2 options.

1)将场景大小设置为1024X768(横向)或768x1024(纵向),并使用默认的.aspectFill进行缩放模式。这是Xcode 7中的默认设置(iPad分辨率)。

1) Set scene size to 1024X768 (landscape) or 768x1024 (portrait) and use the default .aspectFill for scale mode. This was the default setting in Xcode 7 (iPad resolution).

您通常只在顶部/底部(横向)或左/右(纵向)显示一些额外的背景在iPad上。

You than usually just show some extra background at the top/bottom (landscape) or left/right (portrait) on iPads.

在iPad上显示更多内容的游戏示例:

Examples of games that show more on iPads:

Altos Adventure,Leos Fortune,Limbo ,The Line Zen,Modern Combat 5.

Altos Adventure, Leos Fortune, Limbo, The Line Zen, Modern Combat 5.

2)Apple将xCode 8中的默认场景大小更改为iPhone 6/7(750 * 1334-Portait,1337 * 750 -景观)。此设置将在iPad上裁剪您的游戏。

2) Apple changed the default scene size in xCode 8 to iPhone 6/7 (750*1334-Portait, 1337*750-Landscape). This setting will crop your game on iPads.

两个选项之间的选择取决于您,取决于您正在制作的游戏。我通常更喜欢使用选项1并在iPad上显示更多背景。

Chosing between the 2 options is up to you and depends what game you are making. I usually prefer to use option 1 and show more background on iPads.

无论场景大小,缩放模式通常最好保留为默认设置.aspectFill或.aspectFit

Regardless of scene size scale mode is usually best left at the default setting of .aspectFill or .aspectFit

要调整设备的标签等特定内容,您可以这样做

To adjust specific things such as labels etc for a device you can do it this way

 if UIDevice.current.userInterfaceIdiom == .pad {
   // adjust some UI for iPads
 }

我不会尝试在差异设备上手动更改场景或节点大小/比例的随机黑客,你应该让xCode / SpriteKit为你做。

I would not try to do some random hacks where you manually change scene or node sizes/scales on difference devices, you should let xCode/SpriteKit do it for you.

希望这有助于

这篇关于Spritekit将游戏扩展到iPad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆