How do Openfl and Starling handle resolution and scaling in multiple devices?

Hi.

I saw in other 2D framework that they define game’s logical dimensions (say 940x600) and developer provides images with many diferent resolutions.

Say,
bg.png has 940x600 pixels,
[email protected] has 1410x900 pixels
[email protected] has 1840x1200 pixels.
Framework automatically tries to use tje image whose dimensions are the nearest to devices’ physical dimensions, up or downscaling it as needed.

But in this framework developer has to calculate dx and dy dsiplacemen based on logical and real dimensions and this dx and dy must be added to set positions of images.
Eg.: instead of setPosition (100, 200) one has to write set Position (100+dx, 200+dy).

I tried to apply this concept without too much success. Manu years ago, when openfl still was named NME, I’ve made some games but as my target was Flash I didn’t have to worry about handling multiple dimensions.

Any help is very much appreciated.

My approach: define base resolution, calculate positions in percent. On different resolution I recalculate positions according percent, keep aspect ratio.

1 Like