iOS 上发布版本和调试版本之间的物理差异 [英] Difference physics between release build and debug build on iOS

查看:39
本文介绍了iOS 上发布版本和调试版本之间的物理差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Box2D 的 iOS 游戏.当我在调试模式下运行它时,一切都很好.当我在发布模式下运行它时,所有游戏对象都会加速,并且游戏对象的质量似乎更高或类似的东西.很奇怪.

I have an iOS game that uses Box2D. When I run it in Debug mode everything is fine. When I run it in Release mode all game objects speed up and it seems like the mass of game objects is higher or something like that. It's very strange.

两个版本的帧速率几乎相同,所以这不是问题.无论如何,游戏中的所有内容都应该与帧速率无关.

The frame rate is pretty much the same on both versions so that isn't the problem. Everything in the game should be frame rate independent anyway.

知道 XCode 中的什么项目设置可能导致这种情况吗?

Any idea's what project setting's in XCode might be causing this?

推荐答案

在 debug 中运行时,编译器并没有做优化,因此二进制文件要大得多,代码也经常做无用功.在 Release 中,优化器(默认为 -Os)运行,它积极地寻找缩小代码的方法.这是开发人员在测试代码时通常应该使用 Release 而不是 Debug 的原因之一,并且只有在他们真正需要 lldb 时才切换到 Debug.

When you run in debug, the compiler does no optimization, so the binary is much bigger, and the code often does useless work. In Release, the optimizer (defaults to -Os) is run, which agressively finds away to shrink the code. This is one reason developers should normally use Release not Debug when testing their code, and only switch to Debug when they really need lldb.

所以有几件事可以在这里发挥作用.首先,Box2D 是包含的项目还是库中的链接?如果是第一个,请确保它同时具有 Debug 和 Release 配置.查看您和 Box2D 的构建设置,看看是否在一个或另一个配置中定义了任何内容(也就是说,您可能会发现 -DSLOW)或一些将要设置(或不设置标志)的定义语句.啊,调试我通常定义 DEBUG=1(在预处理器部分)Box2D(甚至你的代码)可能出于某种目的使用.

So there are several things that could be in play here for differences. First, is Box2D an included project or a linked in library? If the first, make sure it has both a Debug and Release configuration. Look at your and Box2D's Build Settings, and see if there is anything defined in one config or the other (that is you might find a -DSLOW) or some such define statement that would be setting (or not setting a flag). Ah, and Debug I normally defines DEBUG=1 (in the preprocessor section ) which Box2D (or even your code) might be using for some purpose.

如果您找不到其他不同的构建设置,那么您可以通过将调试配置中使用的值从 -O0 实际更改为 -O1、-O2 和 =Os 来查看优化器是否有影响.同样,您可以将发布设置从 -Os 更改为 -O0.

If you cannot find a another build setting different, then you can see if the optimizer is having the affect by actually changing the value used in the Debug configuration from -O0 to -O1, -O2, and =Os. Likewise you can change the Release setting from -Os to -O0.

我猜是 Debug 配置中的DEBUG"设置,Release 中的其他一些定义,或者优化器是原因,通过玩 Debug 和 Release 你可以找出问题所在.事实上,您甚至可以将(临时)DEBUG=1 添加到 Release 配置中.

I'm going to guess that either the "DEBUG" setting in the Debug configuration, some other define in Release, or the optimizer is the reason, and by playing around with Debug and Release you can figure out what is the issue. In fact you can even add (temporarily) DEBUG=1 to the Release configuration too.

这篇关于iOS 上发布版本和调试版本之间的物理差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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