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

问题描述 投票:0回答:1

我刚刚尝试使用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

ios swift xcode simulator
1个回答
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)
© www.soinside.com 2019 - 2024. All rights reserved.