Scaling game for multiple resolutions

I’m developing a space game that will allow the player to zoom in and out as needed. Can anyone recommend a good way to approach this? I was thinking of using device settings, as in iPhone resolution (320 x 480), iPhone 4 (640 x 960) and maybe iPad as different resolutions. Can these be toggled in-game as if one were changing resolutions in the config file, causing appropriately scaled images to be selected? [import]uid: 1560 topic_id: 11798 reply_id: 311798[/import]

Assets (images, sound etc) can be toggled in-game but not resolution. [import]uid: 27965 topic_id: 11798 reply_id: 43026[/import]

You can detect the scale/pixel size of the device and load the appropriate image. Remember corona will autoscale the image, but you can calculate the scaling it does and divide by that amount to undo the scaling it does. You can then calculate new scaling and up the size by that ratio.

Look at section 3 in my tips for some ideas.

http://www.base2solutions.com/walkabout/Corona%20Tips.html

For example if you load an image with newImageRect using 320x480 on a screen thats 640x960 corona will auto scale it to 2x the size. If the image is >= 640x960 no pixelation occurs. The scale factor here is 2.0 You can calculate the scale using:

scaleX = 1/display.contentScaleX  
scaleY = 1/display.contentScaleY  

If you didnt want this image scaled you would load it with 320/scaleX, 480/scaleY

If you wanted a scale factor of 3 instead you could do 320/scaleX*3, 480/scaleY*3

As another example you could do

if scaleX \<= 1.5 then image = "lowres" else image = "highres" end  

then just load image with newImageRect
[import]uid: 8872 topic_id: 11798 reply_id: 43046[/import]

Scaling your images will muck up physics. Why not just use the scale option in the config.lua file?

application = { content = { width = 768, height = 1024, scale = "zoomStretch", }, } [import]uid: 58455 topic_id: 11798 reply_id: 43069[/import]

Can i set in config.lua to detect which device i’m using then do a auto scale?

dont know… something like “if” in config.lua

if system.device == ipad then  
 scale.x = 2  
 scale.y = 2  

realy dont know @_@
but can we do that? [import]uid: 23063 topic_id: 11798 reply_id: 43103[/import]

I’m not planning to use physics so that shouldn’t be an issue.

As for the scale option, the issue I’m wrestling with is how to best make a vast expanse of space playable for both large and small screen devices. I’d want to be able to zoom in to see two ships or out to see a larger area with more.

Imagine two ships in a space game firing on each other from 500 pixels away. There should be a view that presents both ships onscreen even with a screen that’s iPhone 3GS resolution. So that means presenting a 2x zoomed out view. The situation would probably be similar on higher resolution screens, so I’d need a zoom in and out view for them too.

So it seems I will have to have several icon sets and views for this. Thanks for the suggestions. [import]uid: 1560 topic_id: 11798 reply_id: 43107[/import]

I think you guys are making this too hard. Corona will scale based on the setting in config.lua so that the proportions are maintained for all devices.

Am I missing something?

I set mine as above and deployed to my iPhone 4. No problems. [import]uid: 58455 topic_id: 11798 reply_id: 43110[/import]

You’re right. If all you want to do is autoscale for every device just use config.lua. See these posts:

http://blog.anscamobile.com/2010/11/content-scaling-made-easy/
http://blog.anscamobile.com/2011/01/dynamic-image-resolution-made-easy/

And the documentation can be found here:

http://developer.anscamobile.com/content/configuring-projects#Runtime_Configuration:_config.lua

What I was talking about is if you want to do DIFFERENT scaling just for one object, Or you want to specifically load images like a ‘HD’ image in the menu if your res is a certain size. [import]uid: 8872 topic_id: 11798 reply_id: 43112[/import]

Is there any support for graphics that scale, such as SVG graphics? [import]uid: 38858 topic_id: 11798 reply_id: 46577[/import]