无法在spritekit [SWIFT]中为GameScene设置正确的大小 [英] Unable to set the right size for the GameScene in spritekit [SWIFT]

查看:40
本文介绍了无法在spritekit [SWIFT]中为GameScene设置正确的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在用spritekit&迅速,但问题是我在GameViewController中设置了GameScene的大小为size:CGSize(width:750,height:1334)来扩展UIViewController.

Currently I'm making a game in spritekit & swift but the problem is I've set the GameScene size with size:CGSize(width: 750, height: 1334) in GameViewController that extends the UIViewController.

我将尺寸设置为750 * 1334的原因是因为我想为iphone 6发布游戏,但是问题是它会在6plus或iphone 5中错误显示吗?设置尺寸是正确的选择吗?

The reason that I had set the size to 750 * 1334 is because I wanted to publish the game for iphone 6, but the problem is the will it be displayed wrongly in 6plus or iphone 5 ? Was it the right choice to set the size ?

我应该为@ 2x和@ 3x准备图像吗?大多数游戏角色和图像都设置为150 * 150,非常适合750 * 1334环境,但是我应该设置其他资源吗?我担心如果我提交比赛,它将被拒绝.我很想听听这里的专业人士!

Should I prepare the image for @2x and @3x ? Most of the ingame characters and images are set with 150 * 150 and it is well suited for the 750 * 1334 environment but should I set other resources? I fear if I submit my game it will be rejected . I would love to hear from the pros here !

推荐答案

将大小设置为特定值肯定会对不同设备产生影响.例如,如果您在iPad上进行测试,则可能会发现 view 的某些可见部分在iPhone 6设备上不可见.我知道您不是说要支持iPad,但我只是想指出一个事实,如果您对尺寸进行硬编码,您将获得不同屏幕尺寸的不同游戏体验.

Setting the size to a particular value will definitely have implications on different devices. For example, if you test on an iPad, you'll likely find that some parts of the view visible that isn't visible on your iPhone 6 device. I know you didn't say you're supporting the iPad, but I just wanted to point out the fact that you'll get different gaming experiences for different screen sizes if you hard code the size.

话虽如此,根据游戏玩法的不同,多余的空间可能根本不会影响游戏玩法.例如,如果游戏屏幕的边缘包含对整个游戏过程没有影响的背景图像,那么我认为,如果只截掉了背景,则可以硬编码 GameScene 的大小是可以接受的图像.

That being said, depending on how the gameplay is, the extra space might not impact the gameplay at all. For instance, if the edge of your game screen consists of background imagery that doesn't contribute to overall gameplay, I think hard coding the size of the GameScene can be acceptable if all you cut off is the background imagery.

无论如何,为避免这种不一致,建议您尝试将大小分别设置为 view.bounds.width view.bounds.height ,这样可以保证您的屏幕覆盖设备屏幕的整个尺寸.这并不是所有游戏的解决方案,因为它可能会导致缩放问题,但请查看并查看其在不同设备上的外观.

Anyhow, to avoid this inconsistency, I suggest you try setting the size as view.bounds.width and view.bounds.height respectively, which will guarantee your screen spans the full size of your device's screen. This isn't the solution for all games as it may cause scaling issues, but check it out and see how it looks on different devices.

为@ 2x和@ 3x缩放图像并不难,您绝对应该花些时间来做到这一点.

Scaling the image for @2x and @3x is not hard, you should definitely put in time to do that.

这篇关于无法在spritekit [SWIFT]中为GameScene设置正确的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆