Davidobot wrote: ↑Thu Aug 17, 2017 10:17 am
ElasticSpandex wrote: ↑Thu Aug 17, 2017 8:04 am
My problem is that i have no way of testing this for Android. Something like love.window.hasFocus()
Make a small program that prints a random number in an in-window console every second or so. Exit the app on android, wait a few seconds and go back into the app - if any new numbers appeared, then the game was not paused.
I know the game is not paused... I mentioned above, i have a timer that keeps ticking even when you're not in game. I also went ahead and made another timer just for good mesure, same result.
Here is my love.update function :
Code: Select all
function love.update(dt)
if love.window.hasFocus() then
game:update(dt)
end
end
That is it. Everything is in game:update(). What I want to achieve from this is, the game effectivly pausing when the user isn't in the game. (Ie. has pressed the home button, or in another way left the game). It works on windows when you stop having the window focused (as expected). But the game keeps running when I'm on Android.
As I said in the first post, some of the code runs normally, while the rest doesn't run at all. I'm not 100% sure, but I think "if statements" are ignored? It sounds wierd, here's an example:
Code: Select all
-- This is inside game:update()
if titleY < height/6 then
titleY = titleY + 170*scale*dt
end
All this does, is make the title of the game scroll down the screen until it hits the limt. In this case it's height/6 (window height)
It should look like this:
- Screenshot_20170817-151651.png (5.19 KiB) Viewed 7414 times
But if I press the home button while it is still scrolling down, it will keep going until i "re enter" the app
Resulting in this:
- Screenshot_20170817-151706.png (4.91 KiB) Viewed 7414 times
Could this a bug with the Android port?
All this would not be a problem if love.window.hasfocus() actually returned false on Android.
Is there an alternative to love.window.hasFocus() for Android?