This site requires JavaScript, please enable it in your browser!
Greenfoot back
Gevater_Tod4711
Gevater_Tod4711 wrote ...

2013/3/29

Way to check whether you are playing on the webside or offline

Gevater_Tod4711 Gevater_Tod4711

2013/3/29

#
Hi all, I'm trying to create a profile that can be used if you are playing on the webside (using the UserInfo class) and also if you are playing offline (using a file reader/writer). To save and load the data of a player in the UserInfo is not the problem, but I want to use profiles you can create on your own if you are playing offline and therefore I need to use a file reader/writer. The handling of the file readers/writers is also no problem but I need to know whether I am playing offline or online (on the Greenfoot webside). So my question: Is there a way to check whether you are playing online or offline?
danpost danpost

2013/3/29

#
One way is by trying to write a file. If it succeeds, you are offline.
Gevater_Tod4711 Gevater_Tod4711

2013/3/29

#
I also thought of this but wouldn't this cause an error I can't catch? In my worms game I tried to catch such an exception or error. I don't know exactly why I couldn't catch it. Maybe it was only my fail. However, I'll try that. Thank you danpost.
You need to login to post a reply.