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

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

问题描述

当我移植使用SpriteKit到iPad的iPhone应用程序时,我已经能够使用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上看起来不错。更改 Physic World 会更改所有 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天全站免登陆