frame.size不适合iPhone模拟器spritekit swift

时间:2018-08-28 19:54:58

标签: ios swift xcode simulator

我刚刚尝试使用Xcode创建一个Game-Application,然后继续创建新项目。作为定位测试,我只想在屏幕中间放置一个Spritenode。 我刚刚从Gamescene.Swift中删除了所有内容,并添加了以下三行:

Test = SKSpriteNode(imageNamed: "Fail")
Test.position = CGPoint(x: self.frame.width/2, y: 
self.size.height/2)
self.addChild(Test)

在模拟器中,图片位于屏幕的右上角,这很奇怪-我认为。

Xcode版本9.4.1

Code and Simulation as a picture

1 个答案:

答案 0 :(得分:0)

更改Gameviewcontroller.swift可以解决我的问题。

我只是将代码替换为

let scene = GameScene(size: view.bounds.size)
let skView = view as! SKView
skView.showsFPS = false
skView.showsNodeCount = false
skView.ignoresSiblingOrder = false
scene.scaleMode = .resizeFill
skView.presentScene(scene)