首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Scaling SpriteKit游戏

Scaling SpriteKit游戏
EN

Stack Overflow用户
提问于 2016-07-03 01:18:15
回答 1查看 406关注 0票数 0

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

EN

回答 1

Stack Overflow用户

发布于 2016-07-03 15:11:11

根据实际的Swift 2.2,您可以发现:

代码语言:javascript
复制
@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中这样做:

代码语言:javascript
复制
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

代码语言:javascript
复制
let transition = SKTransition.doorsOpenVerticalWithDuration(0.5)
let nextScene = MainScene(size: self.scene!.size)
nextScene.scaleMode = .AspectFit
self.scene?.view?.presentScene(nextScene, transition: transition)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38162666

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档