什么是最好的方法来外观图像拟合蓝框?这个游戏是基于像素的,所以我想保持它的像素化外观。

发布于 2016-07-03 15:11:11
根据实际的Swift 2.2,您可以发现:
@available(iOS 7.0, *)
public enum SKSceneScaleMode : Int {
case Fill /* Scale the SKScene to fill the entire SKView. */
case AspectFill /* Scale the SKScene to fill the SKView while preserving the scene's aspect ratio. Some cropping may occur if the view has a different aspect ratio. */
case AspectFit /* Scale the SKScene to fit within the SKView while preserving the scene's aspect ratio. Some letterboxing may occur if the view has a different aspect ratio. */
case ResizeFill /* Modify the SKScene's actual size to exactly match the SKView. */
} 例如,你可以在你的viewController中这样做:
override func viewDidLoad() {
super.viewDidLoad()
if let scene = PreloadScene(fileNamed:"PreloadScene") {
// Configure the view.
let skView = self.view as! SKView
...
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFit
...
skView.presentScene(scene)
}
}或者从一个SKScene过渡到另一个SKScene
let transition = SKTransition.doorsOpenVerticalWithDuration(0.5)
let nextScene = MainScene(size: self.scene!.size)
nextScene.scaleMode = .AspectFit
self.scene?.view?.presentScene(nextScene, transition: transition)https://stackoverflow.com/questions/38162666
复制相似问题