tile based game on variable mobile screens sizes

Monkey Forums/Monkey Beginners/tile based game on variable mobile screens sizes

sionco(Posted 2014) [#1]
Hi all

I'm trying to make a small tilebased puzzle game for Android, with each tile being the same size (for example 64x64) and having for example, 6 columns and 4 rows.
but I'm not sure how to approach the typical problem of different screensizes.


I know about things such as the Autofit module here on the forums, but that leaves black borders on each side of the game. Any suggestions would be of great help.


Supertino(Posted 2014) [#2]
Use could scale the images based on a percentage of the DeviceWidth and/or height.

i.e, I need 6 columns to fit across the width of ANY size device, id do this.

local myImage:Image = LoadImage("thing.png") ' load an image
local split:Float = (DeviceWidth/6.0) ' assuming we want to fit 6 images across the width, so we split the width into 6
local imageBaseSize:Float = myImage.Width ' assumes width and height is the same
local scaleFactor:Float = (split/imageBaseSize) ' get scale we need to apply when drawing
local imageSizeAfterScale:Float = (scaleFactor*imageBaseSize) ' get the actual pixel width of the image when scaled

For local x:Int = 0 until 6
     DrawImage(myImage,x*imageSizeAfterScale,y,0,scaleFactor,scaleFactor)
Next



sionco(Posted 2014) [#3]
Thanks, it works well


Gerry Quinn(Posted 2014) [#4]
I tend to work out the width and height of a cell based on the device with or height, then set them both to the smaller value of the two.