SpriteKit iPhone/iPad 不同的分辨率,需要相同的物理 [英] SpriteKit iPhone/iPad different resolution, need same physics

查看:22
本文介绍了SpriteKit iPhone/iPad 不同的分辨率,需要相同的物理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将使用 SpriteKit 的 iPhone 应用程序移植到 iPad 时,我已经能够使用 iPhone 5 与 iPad 屏幕的高度比来缩放所有屏幕元素和字体大小.

As I am porting an iPhone app that uses SpriteKit to iPad, I have been able to scale all the screen elements and font sizes using the height ratio of the iPhone 5 to iPad screen.

一切看起来都是成比例的,除了物理,因为面积更大.

Everything looks proportional, except for the physics since there is more area.

所以问题是,我如何使用该高度比缩放物理和屏幕?

So the question is, how do I scale the physics along with the screen using that height ratio?

也许会改变所有节点的密度或质量?我将如何做到这一点,在数学上使用比率使其完美?

Perhaps changing density or mass of all the nodes? How would I do it, mathematically using the ratio so that it is perfect?

推荐答案

您可以配置 SKPhysicsWorld 对象附加到 SKScene.
它改变了:

You can configure the SKPhysicsWorld object attached to the SKScene.
It changes:

  • gravity 属性,在模拟中将加速度应用于基于体积的物体.
  • speed 属性决定了模拟运行的速率.
  • The gravity property that applies an acceleration to volume-based bodies in the simulation.
  • The speed property determines the rate at which the simulation runs.

您可以将这些 属性 设置为在 iPad 上对您来说不错的值.改变物理世界会改变所有SKObjects的物理.

You can set those properties to values that seems good to you on an iPad. Changing the Physic World changes physics for all SKObjects.

这篇关于SpriteKit iPhone/iPad 不同的分辨率,需要相同的物理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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