gpt4 book ai didi

ios - 我是否需要为每个新的 .swift 文件创建一个新的 SpriteKit 关卡编辑器文件?

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:01:55 25 4
gpt4 key购买 nike

我正在尝试熟悉 Sprite Kit 关卡编辑器。默认情况下,有一个“gamescene.sks”文件附加到“gamescene.swift”。

如果我正在制作一个“gameoverscene”或“playscene”,如果我想在关卡编辑器中使用我的游戏,我是否需要同时创建它们(.swift 和 .sks)?

另外,我对它的大小管理很感兴趣。我正在制作一款通用设备游戏。我应该更改它的默认大小 (1024x768) 还是不打扰?

场景 Canvas 看起来是水平的,如果我的游戏只有纵向模式,我应该改变它吗?

最佳答案

简短回答。是的。

原因..

每次你想呈现或加载一个.sks文件,你需要用这样的类加载它

let doors = SKTransition.doorwayWithDuration(1.0)
let archeryScene = GameScene(fileNamed: "GameScene")
self.view?.presentScene(archeryScene, transition: doors)

如果你看常量用类加载文件

MyScene(fileNamed: "MyScene")

是的,每个 .sks 文件都需要一个 .swift 文件。

有关 .sks 文件的更多信息,请查看此处。

Techotopia - An iOS 8 Swift Sprite Kit Level Editor Game Tutorial

此外,当我使用 Spritekit 关卡编辑器时,我通常将场景大小设置为 960 x 640 以支持最小的 iPhone。如果您有 @1x、@2x、@3x,可能还有 @1x~iPad@2x~iPad,一切都会好起来的。只需确保在 ViewDidLoadinitWithSize(CGSize) 中添加 self.scaleMode = .AspectFill。 您可以将其设置为任何值可能是。您的选择是,

SKSceneScaleMode.Fill

Each axis of the scene is scaled independently so that each axis in the scene exactly maps to the length of that axis in the view.

SKSceneScaleMode.ResizeFill

The scene is not scaled to match the view. Instead, the scene is automatically resized so that its dimensions always matches those of the view.

SKSceneScaleMode.AspectFit

The scaling factor of each dimension is calculated and the smaller of the two is chosen. Each axis of the scene is scaled by the same scaling factor. This guarantees that the entire scene is visible, but may require letterboxing in the view.

SKSceneScaleMode.AspectFill

The scaling factor of each dimension is calculated and the larger of the two is chosen. Each axis of the scene is scaled by the same scaling factor. This guarantees that the entire area of the view is filled, but may cause parts of the scene to be cropped.

(感谢@epicbyte - Dealing with different iOS device resolutions in SpriteKit)

关于ios - 我是否需要为每个新的 .swift 文件创建一个新的 SpriteKit 关卡编辑器文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29009957/

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