SpriteKit游戏开发点滴(3) 屏幕大小模式

本文介绍了SpriteKit中的四种屏幕大小模式:Fill、AspectFill、AspectFit和ResizeFill。AspectFill是最常用的模式,能保持原始屏幕比例并完全覆盖适配屏幕,但可能有部分内容无法显示。AspectFit则确保原始内容完整显示,但可能会用黑色填充空隙。ResizeFill模式的实际效果不明确。适配技巧将在后续内容中讨论。
摘要由CSDN通过智能技术生成

SpriteKit的屏幕大小模式有如下四种:

@availability(iOS, introduced=7.0)
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. */
}

下面逐一进行解释,为了方便解释,我们不妨将原始屏幕的大小设置为1536*1536(正方形),并设置同样大小的背景图片居中显示,然后观察其显示效果:

原始图片的效果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值