Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Saving a level on android, reading files and testing file if it works.

Author
Message
THE_NOTORIOUS_PIGGY
8
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 30th Jun 2016 09:29
I have a level variable in my game that is default to 0. When a player play my game that number increase after completion of a level and I want to save it, and after the app is closed and re-open, that variable needs to be read and saved. From my understanding, this is what i can do

After every level complete, i call this
OpenToWrite ( 1, "myfile.txt", 0 )
WriteInteger ( 1, level )
CloseFile ( 1 )

So it should saving the level. Now, i am making my game on android. I use the agk app to broadcast. How can i confirm that this level saving works? Do i need to export the game and install .apk through a root browser on my android device and verify that file is safed?

Another problem I facing is after loading app after closing, I have a title screen. On it a virtual button that says "play". If pressed, it sets level = 1 so the game works but i tried ReadInteger(level), but it doesnt exist because it is just test from agk software. Is there a way i can use IF statement to do something like if a save file exists form previosly playing, ReadInteger(level) ELSE level = 1

I couldn"t finding a lot of documentation on saving, only the official agk website

Sorry for my English, it is not my first language. I tried my best
Very thank you for your help friends
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 30th Jun 2016 15:49
Quote: "After every level complete, i call this
OpenToWrite ( 1, "myfile.txt", 0 )
WriteInteger ( 1, level )
CloseFile ( 1 )"

Correct.

Quote: "Do i need to export the game and install .apk through a root browser on my android device and verify that file is safed?"

Just broadcast it to the device.

Quote: ". Is there a way i can use IF statement to do something like if a save file exists form previosly playing, ReadInteger(level) ELSE level = 1"

Yes, check if the FileExists first. if not, then set level to 1, otherwise read the level number in.
THE_NOTORIOUS_PIGGY
8
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 30th Jun 2016 17:19
Ok thank you my friend is working well

Login to post a reply

Server time is: 2024-09-29 15:15:49
Your offset time is: 2024-09-29 15:15:49