我是否需要为每个新的 .swift 文件创建一个新的 SpriteKit 关卡编辑器文件?
Do I need to create a new SpriteKit level editor file for every new .swift file?
我正在努力适应 Sprite Kit 关卡编辑器。默认情况下,有一个 "gamescene.sks" 文件附加到 "gamescene.swift"。
例如,如果我正在制作 "gameoverscene" 或 "playscene",如果我想使用它们,是否需要同时创建它们(.swift 和 .sks)我的游戏在关卡编辑器中?
另外,我对它的大小管理很感兴趣。我正在制作一款通用设备游戏。我应该更改它的默认大小 (1024x768) 还是不打扰?
还有那个场景 canvas 看起来是水平的,如果我的游戏只有纵向模式,我应该改变它吗?
简答。是的。
原因..
每次你想展示或加载一个.sks文件,你需要像这样class加载它
let doors = SKTransition.doorwayWithDuration(1.0)
let archeryScene = GameScene(fileNamed: "GameScene")
self.view?.presentScene(archeryScene, transition: doors)
如果你看常量加载文件 class
MyScene(fileNamed: "MyScene")
是的,每个 .sks 文件都需要一个 .swift 文件。
有关 .sks 文件的更多信息,请查看此处。
Techotopia - An iOS 8 Swift Sprite Kit Level Editor Game Tutorial
另外,当我使用 Spritekit 关卡编辑器时,我通常将场景大小设置为 960 x 640 以支持最小的 iPhone。 Alsong as you have @1x, @2x, @3x
and possible @1x~iPad
and @2x~iPad
, Everything will be fine.只是为了确保在 ViewDidLoad
或 initWithSize(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)
我正在努力适应 Sprite Kit 关卡编辑器。默认情况下,有一个 "gamescene.sks" 文件附加到 "gamescene.swift"。
例如,如果我正在制作 "gameoverscene" 或 "playscene",如果我想使用它们,是否需要同时创建它们(.swift 和 .sks)我的游戏在关卡编辑器中?
另外,我对它的大小管理很感兴趣。我正在制作一款通用设备游戏。我应该更改它的默认大小 (1024x768) 还是不打扰?
还有那个场景 canvas 看起来是水平的,如果我的游戏只有纵向模式,我应该改变它吗?
简答。是的。
原因..
每次你想展示或加载一个.sks文件,你需要像这样class加载它
let doors = SKTransition.doorwayWithDuration(1.0)
let archeryScene = GameScene(fileNamed: "GameScene")
self.view?.presentScene(archeryScene, transition: doors)
如果你看常量加载文件 class
MyScene(fileNamed: "MyScene")
是的,每个 .sks 文件都需要一个 .swift 文件。
有关 .sks 文件的更多信息,请查看此处。
Techotopia - An iOS 8 Swift Sprite Kit Level Editor Game Tutorial
另外,当我使用 Spritekit 关卡编辑器时,我通常将场景大小设置为 960 x 640 以支持最小的 iPhone。 Alsong as you have @1x, @2x, @3x
and possible @1x~iPad
and @2x~iPad
, Everything will be fine.只是为了确保在 ViewDidLoad
或 initWithSize(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)