Mobile game dev
I haven't found such info on the documentation, so I'm posting a question here:
How can I detect an Android OS back button press, so I can pause my game? In general, is there a way to check if the user has moved the app in the background, so we can pause it?
Regarding screen size, I have set my game aspect ratio to 16:9 or above and I'm curious about the "above" part. Doing a
screen.fillRect(0,0,screen.width,screen.height,"#111") in the
draw function, I see that in phones with aspect rations longer than 16:9 (for example 18:9 or 21:9), the filled area leaves two large empty bands above and below the actual play area. Is there a way to force the game to run full screen and have then screen.width and screen.height parameters point to the correct values?
Just to add some more info, regarding how the game looks on a phone, I'm talking about just pointing the browser to the game URL, using the QR code; I haven't tested yet how the exported APK works.
- Use the "Any" aspect ratio. When the size of the window in which the game is placed changes, the values of the screen.width parameter will change.
init = function()
update = function()
draw = function()
screen.drawRect( 0, 0, screen.width, screen.height )
screen.drawRect( 0, 0, screen.width-8, screen.height-8 )
screen.drawText( "screen.width = "+screen.width ,0,0,20)
screen.drawText( "screen.height = "+screen.height,0,-20,20)
On my old phone (android 6) the apk doesn't work. And they are suspiciously small.
Thanks, that did the trick.
Here is the final result, for anyone interested: