Page 1 of 1

Possible to save on window close?

PostPosted: Tue Jul 03, 2012 6:26 am
by lverona
I know how to save a game when pressing a key, like Esc. Question is - is it possible to catch the player closing the window and saving before closing the application? Problem is, with my recent maze game people forget to press Esc, they just close the window and saving never happens.

Re: Possible to save on window close?

PostPosted: Tue Jul 03, 2012 7:28 am
by skydereign
Nope, there is no way of tying events to the closing of the game. That'd be a nice feature though. At that point though, you could every so often (perhaps every second) save a temporary file. That way when the window is closed, and you reload the game, it can check for a temporary file and load from that.

Re: Possible to save on window close?

PostPosted: Tue Jul 03, 2012 7:46 am
by schnellboot
or you can make a separate exit button and hope for the user click on that 8)

Re: Possible to save on window close?

PostPosted: Tue Jul 03, 2012 5:44 pm
by lverona
skydereign: Does it take a lot of resources to write a file often?

Re: Possible to save on window close?

PostPosted: Tue Jul 03, 2012 5:58 pm
by skydereign
It can depend on the size of the file you want to write, but generally no it isn't very expensive.

Re: Possible to save on window close?

PostPosted: Tue Jul 03, 2012 6:09 pm
by schnellboot
lverona wrote:skydereign: Does it take a lot of resources to write a file often?

it depends on how much u write everytime but I would say no

Re: Possible to save on window close?

PostPosted: Thu Jul 05, 2012 12:48 pm
by lverona
the save file is around 200-300 bytes