|
  
|
|
|||||||
| Development Discussions All developers who are coding games may stop by here for any help, suggestions, and everything development related. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Zune Guardian
|
Okay so how would I make it so I could save... I think 4 different types of data?
and int and 3 bytes, and then be able to read them back as soon as the game starts again. On a side note: Does anyone know how to display how long the song has been playing/how long it is? So it would look like: 1:53/4 7
__________________
Invisible Text. =P To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. |
|
|
|
|
|
#2 (permalink) |
|
zB Programmer
Experienced Member Join Date: Mar 2007
Posts: 975
Reputation: 119
|
MediaPlayer.PlayPostition is where you are
MediaPlayer.Queue.ActiveSong.Duration is how long it is There are a couple ways to save/read data, but both need to start like: Code:
IAsyncResult result; result = Guide.BeginShowStorageDeviceSelector(PlayerIndex.One, null, null); StorageDevice device = Guide.EndShowStorageDeviceSelector(result); Code:
if (device.IsConnected)
{
You then have to open a storagecontainer for your game/app and specify where you want the file saved and named Code:
StorageContainer container = device.OpenContainer("MyApp");
String filename = Path.Combine(container.Path, "My File.txt");
to read Code:
if (File.Exists(filename))
{
StreamReader reader = new StreamReader(filename);
If you are writing to a file you dont need the file check, and instead of StreamReader you use StreamWriter. For writing your int and bytes you would use you streamwriter variable like so Code:
writer.WriteLine(YourInt); writer.WriteLine(1stByte); writer.WriteLine(2ndByte); writer.WriteLine(3rdByte); For reading your values, you would just use the reader variable like Code:
while (reader.Peek() >= 0)
{
variable = reader.ReadLine();
}
After finishing reading you would again close the reader and dispose the container. You also need this at the very top Code:
using System.IO;
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. Last edited by LedZepp : 07-08-2008 at 01:36 PM. ![]() |
|
|
|
|
|
#3 (permalink) | |
|
Zune Guardian
|
Quote:
I'll see if I can get this to work. Thanks!
__________________
Invisible Text. =P To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. |
|
|
|
|
|
|
#6 (permalink) |
|
Jr. Member
Join Date: Jun 2007
Posts: 407
Reputation: 77
|
I'm making do by taking a class and running it through the XML serializer into an XML document, then saving the XML document to the local storage. Ditto coming back out: load the XML, deserialize into a class.
![]() |
|
|
|
|
|
#7 (permalink) |
|
you lost the game.
zB Programmer
Section Staff Zune Freak Join Date: May 2008
Posts: 1,218
Reputation: 462
|
@Tiptup300: No, there isn't. The API is designed for the Xbox, where it can prompt the user for a location to store their stuff, however, on the Zune, it allocates a folder and returns the path to it no matter what.
@ShotgunSnipist: You might also want to try BinaryWriter/BinaryReader. Those classes let you write strings, numbers, and byte arrays to a file in raw form. Using XML will cause a large delay when users start your game, as it doesn't have to load the XML parser (System.Xml.dll) unless you use it. System.Xml.dll is by far the largest file in the XNA runtime.
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. signature by To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
#8 (permalink) |
|
Jr. Member
Join Date: Jun 2007
Location: Mass
Posts: 312
Reputation: 78
|
Fantastic answer LedZepp - very helpful for my new game im workign on, asteroids:
http://www.zuneboards.com/forums/dev...asteroids.html But really, VERY helpful!!!!!! ![]() |
|
|
|
|
|
#9 (permalink) |
|
Experienced Zuner
|
Is there a way to write or save any other file to the hardrive than a txt file? Would it be possible to make like a paint program and then save the image that is on the screen to the hd for access later?
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
#11 (permalink) |
|
zB Programmer
Jr. Member Join Date: May 2008
Location: Bremen, germany
Posts: 454
Reputation: 246
|
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. Last edited by DiNoGames : 07-19-2008 at 11:32 PM. ![]() ![]() ![]() ![]() |
|
|
|
|
|
#12 (permalink) |
|
Experienced Zuner
|
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
#13 (permalink) | |
|
zB Programmer
Experienced Member Join Date: Mar 2007
Posts: 975
Reputation: 119
|
Quote:
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
|
#14 (permalink) |
|
Experienced Zuner
|
ok thanks... I just didn't understand properly... my bad.
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
#15 (permalink) |
|
Zuner
Join Date: May 2008
Posts: 75
Reputation: 53
|
If anyone's confused about how to write and read binary files, this is the code I used in my game:
Code:
public void GetOptions()
{
if (File.Exists(Path.Combine(container.Path, "options.dat")))
{
BinaryReader dataFile;
dataFile = new BinaryReader(new FileStream(Path.Combine(container.Path, "options.dat"), FileMode.Open));
cantSelectRevealed = dataFile.ReadBoolean();
flagWithPlay = dataFile.ReadBoolean();
selectedSkin = dataFile.ReadInt32();
dataFile.Close();
}
else SetOptions();
}
public void SetOptions()
{
BinaryWriter dataFile;
dataFile = new BinaryWriter(new FileStream(Path.Combine(container.Path, "options.dat"), FileMode.Create));
dataFile.Write(cantSelectRevealed);
dataFile.Write(flagWithPlay);
dataFile.Write(selectedSkin);
dataFile.Close();
}
![]() |
|
|
|
|
|
#16 (permalink) |
|
Experienced Zuner
|
Is there a way to save the current zune screen to a jpeg file or someother kind of file that will know the color of the pixels on the screen.
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
#17 (permalink) |
|
you lost the game.
zB Programmer
Section Staff Zune Freak Join Date: May 2008
Posts: 1,218
Reputation: 462
|
Well, you could render to a RenderTarget, which lets you get a Texture2D of everything you rendered. Not sure what you would want a JPEG for, as XNA itself can't read JPEG files, and there isn't an effective way of uploading files back to the computer.
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. signature by To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
#18 (permalink) | |
|
Experienced Zuner
|
Quote:
oh ok... however this sparks another question. So if you RenderTarget and get a Texture2D of the screen, would it then be possible to save the Texture to the HDD and then load it when you start the app again?
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|