[iOS][GOOI] Button location and inconsistent game size

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Posts: 36
Joined: Sun Mar 15, 2015 9:53 am

[iOS][GOOI] Button location and inconsistent game size

Post by drikdrok » Wed Sep 19, 2018 7:08 pm

So I have this bizarre problem, that only happens on the 'plus iPhones' (6, 7 & 8 plus).

When I start my game, on a physical device, love.resize will be called twice. It will also be called every time you either enter the game, or press the home button. This really messes with love.graphics.getWidth & height for some reason. This is what happens:

First time you open the game, it will resize twice, and love.graphics.getDimensions will return 475, 845. All great, everything works perfectly. Now if you double-tap the home button. You'll see the dimensions now become 414, 736. And if you enter the app again, it will return to 475, 845.

This is where it kinda becomes a GOOI question (the library I'm using for buttons). After i have returned from the double-press home button, my buttons will now be off. When trying to press the buttons where they are drawn, nothing happens, it will instead be where they would have been at resolution 414 by 736 (the one it changes to when double pressing). My problem is, the buttons only behave normally after the first 2 resizes. After that, they're off. I suspect this has to do with how I handle scaling and resizing, so here's the relevant code:

Code: Select all

	--I've defined a bunch of buttons somewhere

	gameCanvasScaleX = love.graphics.getWidth() / 405 -- 405, 720 is the original resolution of the game
	gameCanvasScaleY = love.graphics.getHeight() / 720

	gameCanvas = love.graphics.newCanvas(405, 720)
        gooi.sx = gameCanvasScaleX
        gooi.sy = gameCanvasScaleY
        gooi.sx = gameCanvasScaleX -- Probably isn't needed, but I'm doing it to be sure
 	gooi.sy = gameCanvasScaleY
 	--I then draw everything into the canvas
	love.graphics.draw(gameCanvas, 0, 0, 0, gameCanvasScaleX, gameCanvasScaleY) -- Scale Everything

	gameCanvasScaleX = w / 405
	gameCanvasScaleY = h / 720
I have attached the .love file for good measure.

To return back to the weird resizing that happens, now on my device, when I open the app, the game only resizes once, and the buttons don't work anymore. Is this just some weird quIrk with iOS or Löve? It's important to note that this does not happen on the simulators on Xcode nor on any other iPhones.

So to sum up my questions; Why is the game resized when opened, and how do you properly resize and scale GOOI buttons?

Thanks :awesome: !

I am pretty confident I'm doing resizing properly, since it does work when resizing on windows. So I guess it has to do with the weird resizing that happens on device?
(6.4 MiB) Downloaded 81 times

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests