Precaution about using "zoomEven"

I’m posting this warning for those working on a game that uses the device screen scaling method “zoomEven” and physics. The uneven-ratio scaling performed by zoomEven can often (always?) throw off the physics alignment in your game, making objects visually appear in one place while their physics bodies are located in another place (from a sensory standpoint).

This will apparently be fixed in a future version of Corona. For now, it’s a poorly-documented “bug” that I encountered a week ago. Since then, I had to switch my entire game over to the “letterbox” display setup, basically making all of the zoomEven effort futile. Not a huge annoyance or something that can’t be worked around… I just want to warn any users about this before they undertake zoomEven scaling and physics at the same time.

This being said, there might be a way to set up zoomEven and physics properly in the current version of Corona. It just might involve the placement of objects and physics bodies in different places on your screen than you’d ideally like them to be. If anybody has found a perfect workaround for this, please post it here! :slight_smile:

Brent
[import]uid: 9747 topic_id: 4533 reply_id: 304533[/import]

Is there any more information you can give regarding this bug? Will the bug show up in the simulator or only when you send to device?

I am just wondering because I am currently using zoomEven in my game and haven’t noticed any issues, but I am only testing it on an iphone 3GS. I currently don’t have access to an iphone 4 or ipod touch 4th gen to test.

In the simulator when I view it as iphone 4 it seems to scale up correctly with all my physics bodies working properly, should I still be concerned?

Thanks for the tip.

-Clark [import]uid: 5786 topic_id: 4533 reply_id: 14424[/import]

Hi Clark,

Good idea… I need to elaborate on this to prevent confusion. In my experience and testing, the physics bodies became “confused” primarily (if not specifically) when simulating the iPad while also declaring a 2:3 aspect ratio in “config.lua”, such as the iPhone3 or iPhone 4. When I simulated both iPhone models, the physics worked perfectly, same as you’re confirming in your game.

I think the reason for this “bug” happens when zoomEven scales to aspect ratios different from the one you dictate in your configuration. Speaking in terms of portrait orientation, obviously the iPad screen is proportionally wider than the iPhone screen, so zoomEven will span the entire width but clip off some on the top and bottom. With the Android or Galaxy Tab, it will span the entire height but you’ll lose some on the left and right. I believe this is where the physics bodies lose track of their parent bodies, because the X/Y position is skewed during scaling (a physical body positioned at -100/-100 on iPhone might actually be considered at -100/-120 on iPad, with the image being offset by 20 pixels while its physics body remains elsewhere)

Now, if you’re doing a separate build for iPad, you can probably tweak your game to the iPad ratio and everything will be perfect. But if you’re designing for a universal build, my personal suggestion is to use “letterBox” scaling and fill in the black bar area with other content, or find another workaround. It totally depends on the game… some games can easily be adapted to zoomEven. My game uses alot of physics bodies and I want them positioned in reference to a 0,0 center point in the exact center of the screen. So I opted for letterbox scaling versus zoomEven, but in a future game I will look into using zoomEven again, as I generally prefer the concept of that scaling method.

Regardless, the documentation states that this bug will be addressed in a future release… but until then (it could be soon, it could be in the distant future) we need to find a way to deal with it.

Hope this helps clarify things!

Brent [import]uid: 9747 topic_id: 4533 reply_id: 14433[/import]