About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Maximized?
Author Message
cmontiel Offline
Member

Post: #1
Maximized?
How to know when an app is maximized?, I need to refresh npc positions after maximize. (iOS / Android)

IRC: irc.freenode.net
Channel: #Esenthel
(This post was last modified: 12-16-2012 05:29 PM by cmontiel.)
12-16-2012 05:28 PM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #2
RE: Maximized?
I've tried to find a solution catching or delegating onResume() event [Android]. No way.
And I don't find a function in EE to know when user resumes the game.

Some advice plz?

IRC: irc.freenode.net
Channel: #Esenthel
12-18-2012 05:46 PM
Find all posts by this user Quote this message in a reply
Skykill Offline
Member

Post: #3
RE: Maximized?
Hi, i don't know if Android call the Update function when an application is minimized but i have think of something like that.

Code:
clock_t update_position_time;
Bool Update()
{
    if (static_cast<double>(clock() - update_position_time) / CLOCKS_PER_SEC > 1)
    {
        // Update position.
    }
    update_position_time = clock();

    return true;
}

Basicaly update the position if the application has not been updated for one second. Probably not a good way, but it could be a workaround.
12-18-2012 07:37 PM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #4
RE: Maximized?
- Npc positions are controlled by server.
- Android and iOS don't call nothing when application is in background (that's why I need refresh positions after resume).
- Not a good way, and not safe, there are several situations where something can delay the game more than 1 second without minimize.
- I will need to know it for more things like refresh ads and other things.

For android, esenthel uses NativeActivity and android_native_app_glue which send this event for sure...

IRC: irc.freenode.net
Channel: #Esenthel
12-18-2012 11:36 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Maximized?
I'll add following callbacks to Application class
void (*paused )( ); // pointer to custom function called when application is being paused (lost focus), this function is used only on mobile platforms, default=NULL
void (*resumed )( ); // pointer to custom function called when application is being resumed (gained focus), this function is used only on mobile platforms, default=NULL
12-23-2012 02:37 PM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #6
RE: Maximized?
A lot of thanks!! I was going crazy trying to overload the callbacks. pfft

IRC: irc.freenode.net
Channel: #Esenthel
12-23-2012 06:40 PM
Find all posts by this user Quote this message in a reply
Post Reply