PDA

View Full Version : How do I create a save game feature for a game ?



marvinkong
January 11th, 2005, 10:54 PM
I would wanna know how to create a save game feature available in a flash game . Do I need to use XML intergration or can I just use a txt ?

How do I make flash enter the variables instead of the player to create the save game himself by creating a text file ? (means that flash creates the txt or XML its self) .

And I would , too , wanna know how to make flash read the specific text file and load up the game according to the variables included in it . (Like , the time saved , amount of money in game , the items the players had acquired in game etc.)

Im not making a multiplayer game , I'm making a single player game instead . I hope you all could provide information regarding on this topic .

Im new here so please forgive me if I posted this on the wrong section .

Thanks in advance .

marvinkong
January 12th, 2005, 10:07 AM
*Bump*

Are there anyone here could help ?

RyxiaN
January 12th, 2005, 10:43 AM
No i need the same help

alzor
January 12th, 2005, 11:39 AM
I havent got a good answer for you, but it's going to be quite the proverbial B**ch doing that.

PCGamre
January 12th, 2005, 12:34 PM
This solution is kinda weak but it'll work pretty well (you could probably expand it). Also, it is not exactly as "smart" as you are asking for, but maybe this can give you ideas.... dunno.


At the end of each save point, you can give the user a code. Let's say "1" for level 1, "2" for level 2, etc etc.... Basically, for this example these would be the save passwords.
You could make 1 dynamic INPUT txtbox (for user to type in password) and another regular dynamic txtbox (for the msgbox to tell user if password is correct or not) on the title page of your game. Put it off stage and set focus to it. (or leave it on stage if you want people to see it). Prompt the user to type in the saved point password.
In button, you can put in something like:



on (release, keyPress "<ENTER>") {

// for password 1
if (saveGamecodebox=="1") {
msgbox="Go to level 1";
_root.score = 10000;
_root.health = 100;
// whatever else you wanna do
_root.fade1MC.play();

// for password 2
}else if (saveGamecodebox=="2") {
msgbox="Go to level 2";
_root.score = 20000;
_root.health = 100;
// whatever else you wanna do
_root.fade2MC.play();
} else {
msgbox="Incorrect Password";
}
}

pom
January 12th, 2005, 12:50 PM
The shared objects would be perfect for what you're trying to do (tute on the main site).
Otherwise, you'll have to use PHP :-/

Marz
January 12th, 2005, 11:46 PM
If it is an online style game... I'd just use PHP to make your life alot easier... Storing it in a database... However, if you can't... You can use the password feature above or like pom stated with shared objects...

Good Luck,
- MarZ -

benFusion
May 3rd, 2005, 02:55 PM
If there was a way for Flash to export to a TXT file that would work too, but I dont think that's possible, is it?

Edit: On looking at the Shared Object reference I think that's definately the best way to go:

http://www.kirupa.com/developer/actionscript/shared_objects.htm

so you could have multiple saved games (with different file names) and store whatever variables or items or money the character has in the game. Sounds like a winner... I should learn how to use that one, looks really useful :)

patricktheking
May 3rd, 2005, 07:55 PM
ya... how long variable last? till cookies cleared?

Machuse
July 12th, 2005, 04:33 AM
flash can export to php which can then be stored in mysql. Ill be suprised how easy this method is, if you sit and concentrate. I'm not sure off the top of my head if flash can export to .txt but im sure at least php can. So go from php to txt.

Smee
July 12th, 2005, 05:58 AM
Flash was once able to export to .txt, but that was removed as a security risk, so I doubt you can do it now. About when the "cookies" will clear, they won't. SharedObjects are similiar to cookies, in that location and name of the file matters, but they won't be dissapearing unless the user goes to settings and does it manually.

charmander
July 16th, 2005, 08:38 AM
hi....

i found this subject :

http://www.flashkit.com/movies/Games/Full_Game_Source/Memory_g-Markus_E-8966/index.php


it's looks arounding your conversation ,it's a game that working with "SOL" files....it's a memory game , the player play his game and in the end he had a score in a "sol" file that storing in a new location in:

C:\Documents and Settings\M3\Application Data\Macromedia\Flash Player\localhost

what's great here that the all results get saving in the sol file.....and you can read it another time and the new data you send get harmony with the old data.......

i know this is not like saving a game...but if we send a data and recieve it another time i think we can make a saving mode to our games......

please download the example and then try to subdue it for our subject.......
i have either a two subjects seems like this and work with txt files...but it's working with macromedia stand alone driver only (the flash 5 driver)...but this working with all flash drivers even work if you publish the game like EXE

Smee
July 16th, 2005, 04:18 PM
Yes, that's a good example of the uses of SharedObjects. As long as the person playing doesn't rename or move the file, his scores will always be there :/

charmander
July 16th, 2005, 04:34 PM
dear smee....

can we make a file that we but in it a text field as (in Put)to write a number , and apply button and load button and delete button to control on the data in file........to try what's the file need to transform it to a(game saving file)...and then we can subdue it like our need....

Smee
July 16th, 2005, 04:55 PM
You can use SharedObjects to store any kind of variable, so you can use it for almost anything really. I've attached an example.

You just need to remember that the saved information can only be accessed by the original name, location, and file type (a projector, which is a .exe cannot access SharedObjects that a .swf saved) that saved it.

charmander
July 16th, 2005, 05:07 PM
really i had surprised...you are very fast and smart.......i tried your work but some operates dosen't work correctly...when you click increase or decrease the number doesn't getting more or less but the number get behind the number i edit....what's your opinion??

charmander
July 16th, 2005, 05:12 PM
i tried it for a secound time ....it's work once correctlly and another time like i tell you in the last replay....

charmander
July 17th, 2005, 03:15 AM
Dear smee….
the file is will be so good if we change the text field from input to dynamic…then it's go to be the best data saver file I saw ……but I think the only problem you will find that's when we press delete key the value of the number being "undefined",can you solve this…..i mean if you change the text field to dynamic and then press delete you can't then work with file as you planed……

and about the exe, you said that the projector file can't work with the shared object....but it have worked with me...as like as working in swf file and make the sol file and change on it.....

Smee
July 17th, 2005, 08:39 PM
1. It is suppose to say "undefined", because the variable has been deleted.

2. What I meant about the .exe is that if you save a SharedObject with an .swf, you won't be able to access that SharedObject with an .exe because the file type is different, even though the name and location is the same.

charmander
July 17th, 2005, 11:28 PM
then...i think you success in this (data saver).......if you use it in this case (like save a level in a game and load it for another time and complete it)

bandinopla
July 18th, 2005, 02:57 PM
Thats easy:

U have 2 options...

1- save te game in a database with php or asp... and later, load them (this remains the ime U need)
2- save the game in a temp object in flash (but that remains until the window close)

If U have questions...

Smee
July 18th, 2005, 06:50 PM
1- save te game in a database with php or asp... and later, load them (this remains the ime U need)

That would be the best method to save something like a character file in a game, since it's unlikely to be lost by accident, and also very secure.


then...i think you success in this (data saver).......if you use it in this case (like save a level in a game and load it for another time and complete it)

Going back to SharedObjects for now though. you would just save the information you need for the level instead of the number used in my example. for character position, save it into an object like {x: #, y: #}, and use SharedObjects to save it.


function saveGame(){
mySO.data.character_Position = {x: Character._x, y: Character._y};
}

TrapHole_2032
July 22nd, 2005, 05:39 AM
Can anyone explain WHAT they mean by using PHP or ASP???
With the ActionScript too.
Sorry, I'm still a newbie. :cap:

Thx

Darkfuzz
August 14th, 2005, 11:47 PM
So, could anyone elaborate on how to save the variables to a database or something on the internet, to be recalled later? I'm working on a multiplayer game that will need every user's information to be in one spot.

Tutorials/explanations/anything will do. Thanks!

TrapHole_2032
August 15th, 2005, 11:54 AM
Hmm..
Using a database..


Can anyone provide a Tutorial about it?
Thx..