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.
Any idea’s what project setting’s in XCode might be causing this?
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.
EDIT: 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.
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.
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.