Possible to save on window close?

Non-platform specific questions.

Possible to save on window close?

Postby lverona » Tue Jul 03, 2012 6:26 am

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.
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Possible to save on window close?

Postby skydereign » Tue Jul 03, 2012 7:28 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Possible to save on window close?

Postby schnellboot » Tue Jul 03, 2012 7:46 am

or you can make a separate exit button and hope for the user click on that 8)
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Possible to save on window close?

Postby lverona » Tue Jul 03, 2012 5:44 pm

skydereign: Does it take a lot of resources to write a file often?
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Possible to save on window close?

Postby skydereign » Tue Jul 03, 2012 5:58 pm

It can depend on the size of the file you want to write, but generally no it isn't very expensive.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Possible to save on window close?

Postby schnellboot » Tue Jul 03, 2012 6:09 pm

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
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Possible to save on window close?

Postby lverona » Thu Jul 05, 2012 12:48 pm

the save file is around 200-300 bytes
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron