我是否需要为每个新的.swift文件创建一个新的SpriteKit级别编辑器文件? [英] Do I need to create a new SpriteKit level editor file for every new .swift file?

查看:103
本文介绍了我是否需要为每个新的.swift文件创建一个新的SpriteKit级别编辑器文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Sprite Kit级别编辑器。默认情况下,有一个gamescene.sks文件附加到gamescene.swift。

I'm trying to get comfortable with Sprite Kit level editor. By default, there is one "gamescene.sks" file that's attached to "gamescene.swift".

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

If i'm making a "gameoverscene" or "playscene" for example, do I need to create both of them (.swift and .sks) if I want to work with my game in the level editor ?

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

Also, I'm interested in it's size management. I'm making a universal devices game. Should I change it's default size (1024x768) or do not bother ?

此场景画布看起来也是水平的,如果我的游戏只是纵向模式,我应该更改吗?

Also that scene canvas looks horizontal, should I change it if my game is a portrait-mode only ?

推荐答案

简答。是。



原因..



每次要呈现或加载.sks文件时,您需要用类似的类加载它



Short Answer. Yes.

Reason..

Every time you want to present or load an .sks file, You need to load it with a class like so

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



< h3>如果你看一个常量加载文件的类

MyScene(fileNamed:MyScene)


Techotopia - iOS 8 Swift精灵套件关卡编辑器游戏教程

当我使用Spritekit时关卡编辑器,我通常将场景大小设置为960 x 640支持最小的iPhone。 Alsong,因为你有 @ 1x,@ 2x,@ 3x ,可能 @ 1x~iPad @ 2x~iPad ,一切都会好的。只是为了确保在 ViewDidLoad initWithSize(CGSize)中添加 self.scaleMode = .AspectFill。您可以将其设置为可能的范围。您的选择是,

Also when I use the Spritekit Level Editor, I usually set the Scene size to 960 x 640 to support the smallest iPhone. Alsong as you have @1x, @2x, @3x and possibly @1x~iPad and @2x~iPad, Everything will be fine. Just to be sure in the ViewDidLoad or the initWithSize(CGSize) to add self.scaleMode = .AspectFill. You can set it to what ever it may be. Your options are,

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




计算每个维度的比例因子,并且选择了两个。场景的每个轴都按相同的缩放因子缩放。这可以保证整个场景可见,但可能需要在视图中使用letterbox。

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 - 处理SpriteKit中的不同iOS设备分辨率

(Credits to @epicbyte - Dealing with different iOS device resolutions in SpriteKit)

这篇关于我是否需要为每个新的.swift文件创建一个新的SpriteKit级别编辑器文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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