【发布时间】:2017-08-06 10:41:08
【问题描述】:
我正在以编程方式从视图控制器(将difficulty 字符串传递给它)呈现游戏控制器/游戏场景,如下所示:
class GameController: UIViewController {
var difficulty: String!
override func loadView() {
self.view = SKView(frame: UIScreen.main.bounds)
}
override func viewDidLoad() {
super.viewDidLoad()
let skView = self.view as! SKView
let scene = GameScene(size: view.frame.size)
// Set the scale mode to scale to fit the window
scene.scaleMode = .aspectFill
scene.difficulty = difficulty
// Present the scene
skView.presentScene(scene)
skView.ignoresSiblingOrder = true
}
}
但是当场景出现在屏幕上时,所有内容都被“放大”了(SKSpriteNodes、SKLabels 等)
有人知道如何解决这个问题吗?
非常感谢。
PS:通过 SKS 演示可以正常工作,只是在 iPad 上SKLabel 定位存在问题。这种方法的问题是我无法找到如何通过 SKS 将我的自定义变量 difficulty 传递给场景,即使我在 Storyboard 中将其自定义类更改为我的,所以也应该这样做。
【问题讨论】:
标签: ios sprite-kit skspritenode skscene skview