gpt4 book ai didi

ios - 适用于 iPhone 5、6 和 6 plus 的 SpriteKit SKScene 尺寸

转载 作者:行者123 更新时间:2023-11-30 13:25:50 24 4
gpt4 key购买 nike

我正在尝试使用 SpriteKit 为 iPhone 5,6 和 6 plus 构建一个应用程序。我为每个分辨率创建了一个背景图像:

image-1.png    // of size 1136 x 640, for iPhone 5
image-1@x2.png // of size 1334 x 750, for iPhone 6
image-1@x3.png // of size 2208 x 1242, for iPhone 6 plus

在 Xcode 7 中,当我在 iPhone 6 和 6 plus 的模拟器上运行代码时,会自动选取正确且相应的图像。但是,当我运行 iPhone 5 的代码时,会选择 iPhone 6 图像 (image-1@x2.png),而不是正确的图像 (image-1.png)。为什么?

在 SKScene.didMoveToView() 中,我将场景大小设置为 View 的帧大小:

self.size = view.frame.size

当我将图像添加到场景中时,我会:

self.addChild(SKSpriteNode(imageNamed:"image-1"))

如果我使用“image-1.png”,我会得到相同的结果。

最佳答案

没有专门针对iPhone 5和6的地方。它们都拍摄@2x图像。因此,在这两种设备中,它都会选择 @2x 图像。

您需要以编程方式或基于条件进行设置。

引用我的老问题:Images.xcassets taking wrong image for the iPhone 6?

关于ios - 适用于 iPhone 5、6 和 6 plus 的 SpriteKit SKScene 尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37201607/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com