cmontiel
Member
|
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 |
|
cmontiel
Member
|
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 |
|
Skykill
Member
|
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 |
|
cmontiel
Member
|
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 |
|
Esenthel
Administrator
|
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 |
|