how to hide a group if application suspended?

I am building a word game and I want to hide the board when application is suspended?

the code looks fine however it givs a strange behaviour!!,

when I suspend the app nothing will happen but when i resume the application then the board will hide!!

local onSystem = function( event )  
 if event.type == "applicationSuspend" then  
 print("suspend")  
 board\_group.alpha = 0  
 end  
end  
Runtime:addEventListener( "system", onSystem )  

Note: you might wonder how do I know how the application looks when suspended? the answer is: by pressing the home button twice.
Thanks [import]uid: 8519 topic_id: 32856 reply_id: 332856[/import]

If your testing this is in the simulator, I think the suspend happens right away and the onSuspend code executes when you resume.

You need to have something to handle the resume to show the board when you come back. [import]uid: 19626 topic_id: 32856 reply_id: 130609[/import]

If your testing this is in the simulator, I think the suspend happens right away and the onSuspend code executes when you resume.

You need to have something to handle the resume to show the board when you come back. [import]uid: 19626 topic_id: 32856 reply_id: 130609[/import]

robmiracle thanks for trying to help however this will not work in my case because I am building a word game which the player should solve the puzzle in a specific time

current situation: it is easy for players to cheat by just pressing the home button twice then the game will enter the suspension mode without me being able to hide the board (since corona dont fire event applicationSuspended until the app resumes!!)

I hope it is clear and I hope to get any answer from the community or staff???
[import]uid: 8519 topic_id: 32856 reply_id: 130630[/import]

To clarify, the suspend event does fire immediately on suspend (try using print() to prove it). But you can’t change the graphics in that event. So sorry, we can’t do what you want us to do. The event is “application is suspending now”, not “application is suspending, but oh wait, let me do a ton of things and suspend later at some unbounded time”. This is your chance to save application state; it is not intended for you to do much else.

iOS tells us it is suspending and we have to get out of the way immediately and suspend your app. We are not allowed to draw again (Apple may take away OpenGL from us among other things).

Your best bet is one of several things:

  1. Let them cheat, but don’t let them enter high scores based on this.
  2. Invalidate the puzzle completely and make them start a new one.
  3. Record the current suspend time and on resume compare the time difference. If the time was very short, you may be forgiving and subtract it from the current count down. If it was long, do 1 or 2.
    [import]uid: 7563 topic_id: 32856 reply_id: 130631[/import]

robmiracle thanks for trying to help however this will not work in my case because I am building a word game which the player should solve the puzzle in a specific time

current situation: it is easy for players to cheat by just pressing the home button twice then the game will enter the suspension mode without me being able to hide the board (since corona dont fire event applicationSuspended until the app resumes!!)

I hope it is clear and I hope to get any answer from the community or staff???
[import]uid: 8519 topic_id: 32856 reply_id: 130630[/import]

To clarify, the suspend event does fire immediately on suspend (try using print() to prove it). But you can’t change the graphics in that event. So sorry, we can’t do what you want us to do. The event is “application is suspending now”, not “application is suspending, but oh wait, let me do a ton of things and suspend later at some unbounded time”. This is your chance to save application state; it is not intended for you to do much else.

iOS tells us it is suspending and we have to get out of the way immediately and suspend your app. We are not allowed to draw again (Apple may take away OpenGL from us among other things).

Your best bet is one of several things:

  1. Let them cheat, but don’t let them enter high scores based on this.
  2. Invalidate the puzzle completely and make them start a new one.
  3. Record the current suspend time and on resume compare the time difference. If the time was very short, you may be forgiving and subtract it from the current count down. If it was long, do 1 or 2.
    [import]uid: 7563 topic_id: 32856 reply_id: 130631[/import]

Hi ewing, Thanks for your nice reply

there is a way to hide graphics before suspending the game and here is an example

SpellTower in normal state
http://cl.ly/image/0A0n0v1A2q0C/o

SpellTower after pressing the home button twice
http://cl.ly/image/2D0p3I3d3T3h/o
you can see how they are hiding the letters, this is exactly what I want to do for my game

so it is not imposible -I am still optimistic :)-
I believe in cocoa you would use something like this applicationWillResignActive

not forgot to mention that your work around are very smart specially the third one!!

Thanks again

Best regards [import]uid: 8519 topic_id: 32856 reply_id: 130662[/import]

Hi ewing, Thanks for your nice reply

there is a way to hide graphics before suspending the game and here is an example

SpellTower in normal state
http://cl.ly/image/0A0n0v1A2q0C/o

SpellTower after pressing the home button twice
http://cl.ly/image/2D0p3I3d3T3h/o
you can see how they are hiding the letters, this is exactly what I want to do for my game

so it is not imposible -I am still optimistic :)-
I believe in cocoa you would use something like this applicationWillResignActive

not forgot to mention that your work around are very smart specially the third one!!

Thanks again

Best regards [import]uid: 8519 topic_id: 32856 reply_id: 130662[/import]

i posted the question also in stackoverflow.com with a bounty of 400 points , http://stackoverflow.com/questions/13327930/in-corona-sdk-how-to-hide-a-group-if-application-suspended

??? [import]uid: 8519 topic_id: 32856 reply_id: 130827[/import]

i posted the question also in stackoverflow.com with a bounty of 400 points , http://stackoverflow.com/questions/13327930/in-corona-sdk-how-to-hide-a-group-if-application-suspended

??? [import]uid: 8519 topic_id: 32856 reply_id: 130827[/import]

I’m curious, ewing… How about these, any chances of working?

  • Creation of a native field to cover the screen, even that won’t be rendered? (They always seem to render when you don’t want them, and don’t render when ya do want them to, drats!!)

  • Could the issue be pasted over with a local notifcation, as in, when the suspend event occurs, the app fires off a local notification to be received a second later that clears the screen (or are graphics updates prevented in the local notification context as well)?

  • timer.performwithdelay() no good called from the app suspend event, too?

[import]uid: 79933 topic_id: 32856 reply_id: 130858[/import]

I’m curious, ewing… How about these, any chances of working?

  • Creation of a native field to cover the screen, even that won’t be rendered? (They always seem to render when you don’t want them, and don’t render when ya do want them to, drats!!)

  • Could the issue be pasted over with a local notifcation, as in, when the suspend event occurs, the app fires off a local notification to be received a second later that clears the screen (or are graphics updates prevented in the local notification context as well)?

  • timer.performwithdelay() no good called from the app suspend event, too?

[import]uid: 79933 topic_id: 32856 reply_id: 130858[/import]

oooobs: It is not impossible. You are correct that we don’t currently expose resigned/becomeActive.

We have to be careful because in addition to supporting cross-platform issues, Apple themselves has changed the calling order and has bugs we have had to work around through the different iOS versions.

I’m not sure where you are supposed to file feature request nowadays with us, but please do so.
mpappas: Native display objects like textfields/views, movie views, web views, etc. are a clever idea. It might just work, but we can’t guarantee it will work or continue to work.

I don’t know enough about the local notifications if that would work. You would have to try it.

I don’t think timer.performWithDelay will help. We suspend the system that allows timers to fire.

[import]uid: 7563 topic_id: 32856 reply_id: 131194[/import]

oooobs: It is not impossible. You are correct that we don’t currently expose resigned/becomeActive.

We have to be careful because in addition to supporting cross-platform issues, Apple themselves has changed the calling order and has bugs we have had to work around through the different iOS versions.

I’m not sure where you are supposed to file feature request nowadays with us, but please do so.
mpappas: Native display objects like textfields/views, movie views, web views, etc. are a clever idea. It might just work, but we can’t guarantee it will work or continue to work.

I don’t know enough about the local notifications if that would work. You would have to try it.

I don’t think timer.performWithDelay will help. We suspend the system that allows timers to fire.

[import]uid: 7563 topic_id: 32856 reply_id: 131194[/import]