Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site
Thursday
Apr012010

How Does the Emulator Actually Work?

The emulator is written in x86 code, i.e. it is not emulating the actual processor in the phone, like emulators for earlier Windows Mobile devices do. From a developer point of view this is not a problem, in that since all your access to the device is via managed code, the actual nature of the underlying platform is irrelevant. Except for one thing – performance.

There is nothing in the emulator that provides any kind of realistic mapping between the performance you see on your PC and how the program will actually run on the device.  The emulator is functional only. You will have to do tests on a real device to determine the actual performance of any code that you write.

You might find the “How do I create a Frame Counter?” post useful in this respect. If you are having problems getting the emulator running then take a look at “Why won’t the emulator run on my machine?”.

Sunday
Apr112010

What is the Difference between Windows Phone 7 and Zune HD?

From a customer point of view the main difference is that you can buy a Zune HD now, but a Windows Phone purchase remains a distant prospect. However, there are other differences:

The Zune HD can run XNA games developed in Visual Studio 2008 using XNA 3.1. It doesn’t support 3D games, but it does provide multi-touch and accelerometer support (although the Windows Phone accelerometer is accessed in a different way at the moment).

The Zune HD does provide programmatic access to the media content in the same way as Windows Phone will.

If you are thinking of getting a Zune HD as a way of getting started writing 2D XNA games that use multi-touch input then this is not a bad idea. Another plus point to this approach is that you end up with a Zune HD, which is a very well specified media player with a fantastic OLED screen and some lovely features.  Performance wise the Zune HD can handle a surprisingly large number of simultaneous sprites and the Windows Phone hardware will do even better.

Bear in mind that if you are not from the USA you will have to buy a “grey” import device and will not have access to the subscription services.

Thursday
Apr012010

Where can I find Windows Phone Resources?

If you want to get started on Windows Phone development I strongly recommend that you take a look at the videos from Mix. They are very well presented and easy to view on your PC. There is even an HD version of each one.

http://live.visitmix.com/MIX10/Sessions/CL01 – a good introduction to Windows phone and why it is the way it is

http://live.visitmix.com/MIX10/Sessions/CL13 – a good overview of the windows phone and how you build and deploy applications

http://live.visitmix.com/MIX10/Sessions/CL16

http://live.visitmix.com/MIX10/Sessions/CL17 – these two sessions give a very good introduction to Silverlight development on the phone

http://live.visitmix.com/MIX10/Sessions/CL21 – how to use XNA to build games

http://live.visitmix.com/MIX10/Sessions/CL18 – a nice in-depth description of how the phone works internally

You can get the SDK for Windows Phone here.

You can get the first six chapters of the new book from Charles Petzold on Windows Phone development here.

Reddit has a whole bunch of very good links here.

The forums for Windows Phone developers (which are very well staffed with knowledgeable Microsoft moderators) are here.

There is now a Programming Guide for Windows Phone on MSDN which you can find here.

You can get my demos and slide deck from DevDays2010  here.

Monday
Apr122010

Why do I get an “Object reference not set to an instance of an object” error when I run my program?

image 
Scenes we don’t want to see…

Sometimes when you run a Windows Phone program from VS 2010 (usually one that has run successfully before) you get the above message.  This can also happen if you run a program that somebody else has sent you (and claims that it works).

The answer is simple, and has to do with the way that Visual Studio likes to create directory hierarchies as it builds your projects, and the fact that the filing system on your PC has a limited number of characters available for file paths. If you put your VS 2010 projects deep down your folders, in a well organised kind of way, they will fail to run as some of the files can’t be created, can’t be loaded and then produce the above error.

The solution is to move the entire project up a bit in the file system.

Thursday
Apr012010

Why does my XNA Game Not Fill the Screen?

By default an XNA game is overlaid by the phone title bar. This takes up a row at the very top, so draws at 0,0 will not be properly visible. You can request the graphics device in your game to let you use the whole screen by setting its IsFullScreen property to true. The best place to do this is in the constructor for the game class:

public Game1()
{
    graphics = new GraphicsDeviceManager(this);

    // Make the game full screen
    graphics.IsFullScreen = true;

... rest of constructor here