SpriteKit scene自适应

使用Xcode的Game模版,在GameViewController.swift中改写

if let scene = SKScene(fileNamed: "GameScene") {

// Set the scale mode to scale to fit the window

scene.size = UIScreen.main.bounds.size.applying(CGAffineTransform(scaleX: UIScreen.main.scale, y: UIScreen.main.scale))

//增加此行,即可获得设备真实像素大小的scene

scene.scaleMode = .aspectFill

// Present the scene

view.presentScene(scene)

}

你可能感兴趣的:(SpriteKit scene自适应)