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

Entries by Rob (3094)

Wednesday
Aug182010

Windows Phone 7 Training now Live

on the same page

Relive the magic… (and thanks again to pinksugarface for the pic)

If you want to get started on Windows Phone development head on down here for 12 hours of training, neatly broken down into bite sized sections. Andy and I cover getting started, Silverlight, XNA, the Windows Phone Marketplace and lots of other things besides. And if you stay to the end you get to find out who wins their own private jet. Really.

Tuesday
Aug172010

XNA Games and Windows Phone Screens

London bridge

If you are writing games for Windows Phone there are a couple of things worth knowing about how the display works.

Firstly, the top bar of the screen is used to display things like battery level, signal status and the like. This status bar only appears when the user touches that part of the screen, which is good because it makes the whole of the screen available when you don’t want to know your precise signal strength. However in an XNA game you might not want this to appear if the user happens to touch that part of the screen. You can stop the status bar from appearing by telling the graphics adapter to use full screen mode.

graphics.IsFullScreen = true;

Do this in the constructor for your game class, just after the graphics device has been created, and your game will get exclusive use of the entire screen.

The other thing worth knowing is how to stop the screen timeout turning up and ruining the gameplay. The screen will time out if there has been no touch activity for a while, which means that games controlled entirely by the accelerometer may get timed out. You can disable time-out by using the statement:

Guide.IsScreenSaverEnabled = false;

Now your game will run forever, or until the battery goes flat – whichever comes sooner…

Monday
Aug162010

Rob and the Cube

Robs Cube

I wasn’t looking to buy a new car. I never am. Particularly after just having had the current one serviced. But they had some Cubes at the Nissan dealership and I just had to go and have a look. And I think the Cube looks great. (Although opinions differ).

Inside it is a bit like driving a conservatory and I don’t think it will win any speed races. But I really like it. My definition of great car is “A vehicle that transports a really good SatNav and sound system around, along with space for gadgets”. The Cube does all that.  And it has a rear view camera. In colour. The plan is for some trickle down action, with number one wife getting my car so every body wins.

If you are looking to by something mini-MPV’ish with a really distinctive style (the only car I’ve ever owned that I would probably be able to draw a recognisable picture of) then there are some amazing deals on the Cube at the moment.

Sunday
Aug152010

Understanding Windows Phone Orientation in XNA

Panic Orientation

The many orientations of Panic.

Above you can see  my Windows Phone 7 Panic Button application. This gives you a panic button to press at any point in your panic inducing life. To make it work in any orientation I had to do a couple of things.

I had to tell the Windows Phone system the orientations my XNA game can support. I did this in the constructor for the game:

public PanicButtonGame()
{
    graphics = new GraphicsDeviceManager(this);
    Content.RootDirectory = "Content";

    graphics.SupportedOrientations =
        DisplayOrientation.Default |
        DisplayOrientation.LandscapeLeft |
        DisplayOrientation.LandscapeRight |
        DisplayOrientation.Portrait;
    // rest of constructor here
}

This effectively tells XNA that the graphics device for my game can support any way the player might want to hold the phone. The next thing I had to do was get an event fired when the orientation changed so that I could re-position that all important button:

public PanicButtonGame()
{
     // start of constructor here

    Window.OrientationChanged +=
          new EventHandler<EventArgs>
                                (Window_OrientationChanged);

    // Frame rate is 30 fps by default for Windows Phone.
    TargetElapsedTime = TimeSpan.FromTicks(333333);
}

void Window_OrientationChanged(object sender, EventArgs e)
{
    // called when the orientation changes
    positionButton();
}

When the game is running and the player changes the orientation of the phone my method bound to the Window_OrientationChanged event will fire and re-position the button on the screen.

If you game can only support particular orientations then just leave out the ones that you don’t want to make available. 

Things get interesting if you do something stupid with preferred resolutions and orientation:

graphics.SupportedOrientations = DisplayOrientation.Portrait;
graphics.PreferredBackBufferWidth = 400;
graphics.PreferredBackBufferHeight = 240;

I’ve asked to work in Portrait orientation. However, I’ve also asked for a screen which is 400 wide and 240 high (i.e. a landscape one) which is a bit daft. What happens here is that my program will think it has a “screen”  400 wide by 240 high, but this will then be scaled by the hardware to fit in a display working  in portrait mode, which means that I’ll get my screen scrunched into the middle of the screen, with black bands above and below:

image

I’ve added a blue background here so you can see what happens.

If you want to select particular screen orientations and also use the hardware scaler you have to make sure that your selections agree or this will happen to you.

Saturday
Aug142010

Jenny’s Abseil

Jenny Abseil Land

Number one daughter did her abseil today. It got put back from earlier this year. If you sponsored her, well done and thanks very much.

If you didn’t there is still time:

http://www.justgiving.com/jennifer-miles

It was 450 feet you know…