Using Isolated Storage to save/load files on Windows Phone 7

I’m seeing a lot of forum threads with people asking how to save/load files on Windows Phone 7, well for XNA 4 in general. You can use IsolatedStorage for that using System.IO.IsolatedStorage; Both save and load can be done by creating a IsolatedStorageFile, I then use a Filestream and write with a binaryWriter IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication(); // grab the storage FileStream stream = store.OpenFile("test.txt", FileMode.Create); // Open a file in Create mode BinaryWriter writer = new BinaryWriter(stream); float myvar = 5....

October 10, 2010 · 1 min · 153 words · David Amador

A good Reference system can help your game

How many times has it happened where you have this one class, let’s say it’s a spaceship that was destroyed. Now you have tell all other dependent objects that she died, any independent sprite animation class, AI, etc etc because they were relying on her. Another thing is, in my case, having a scene that contains all the objects and by deleting the ship It won’t get removed from the scene, keeping the reference alive and so Garbage collector won’t kick in....

June 6, 2010 · 2 min · 406 words · David Amador

Write better code using FxCop

Microsoft FxCop, know what this is all about? Good for you, keep using it, It’s a valuable tool. For those who don’t know you can download it here and read the MSDN documentation here. FxCop is a is an application that analyzes managed code assemblies and reports information about the assemblies, such as possible design, localization, performance, and security improvements. I decided to make a profile of my current working project and it reported tons of stuff....

March 18, 2010 · 1 min · 107 words · David Amador

C# foreach VS for loop

When I started using C#, mainly because of XNA one of the things I got used to write is foreach loops instead of for, seemed easier and it’s a much cleaner code. Doing almost the same thing as a for loop I never really bother to see the differences, almost everyone in their XNA examples used it instead. Today I decided to see the differences between them: FOR int[] values = new int[1]; int total = 0; for(int i = 0; i < values....

December 12, 2009 · 2 min · 312 words · David Amador

XNA Camera 2d with zoom and rotation

07/01/2011 – By popular request updated to XNA 4.0, xna 3.1 code is still there too One of the things I keep finding is people asking how to do a simple camera 2d in XNA. Today I decided to contribute with my own solution. Most of the time the solution given is to have a class camera with a Vector2 position and when drawing the sprite batch to subtract the camera position to the sprite position itself....

October 12, 2009 · 3 min · 433 words · David Amador