Got Cube
/Picked up my shiny, new-ish, Nissan Cube today. It is every bit as great as I thought it would be. And it has footwells that light up in different colours.
Rob Miles on the web. Also available in Real Life (tm)
Picked up my shiny, new-ish, Nissan Cube today. It is every bit as great as I thought it would be. And it has footwells that light up in different colours.
Ryan, one of our satisfied customers wearing the T-shirt he won on the last jump start. Looking good…
We have had loads of hits on the Windows Phone Jump Start videos. And we are planning another set of sessions in September, which will be bigger, brighter and bang up to date. More details soon.
Now, that’s what I call a flight deck.
We went to see Concorde at Filton today. I always feel a bit sad when we go over there. The plane is amazing but it doesn’t deserve to be stuck on the ground. It really should be out there doing what it does best, and what nothing on earth can do any more.
This time the affair was even more poignant because as of later this year the plane will not be open for visitors at all, which is really sad.
Anyway, I took the big camera and a selection of lenses and tried to get a few shots.
Not surprisingly the team at Bristol is very busy at the moment as people take their last chance to see the plane for a while, but if you can get yourself down there you won’t regret the trip.
It will come as no surprise to you that your Windows Phone programs are interrupted when the phone rings. However, if you are running an XNA game at the time it will not actually stop. This will probably annoy your game player though, as once they come back from explaining that they don’t want any double glazing just right now they will probably find that all their lives have been lost and the game is over.
To get around this you should make your XNA game drop into pause mode when a call comes in. You can get notification of things like phone calls by binding to the Activated and Deactivated events.
this.Activated +=
new EventHandler<EventArgs>(Game1_Activated);
this.Deactivated +=
new EventHandler<EventArgs>(Game1_Deactivated);
You can get Visual Studio 2010 to do all the hard work here, just type “this.Activated +=” and then press Tab in response to the magic that happens next. Then put code into the methods that are generated and away you go.
Note: This is not what happens if the player presses Windows or Back. In those cases your game program is stopped. But that is a subject for another post I think.
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.
I've just discovered that we have had over 11,000 hits on the first episode on Channel 9. Amazing.
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…
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.
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:
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.
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…
The folks at BEPU have made a wonderful 3D physics engine for XNA on Windows Phone. You can see it in action above.
And they’ve now ported it onto Windows Phone. I’ve downloaded the demo software onto my device and initially it ran rather slowly. However, Windows Phone has a lovely trick which makes it unique amongst mobile devices. You can set the display resolution to a lower value and hardware autoscales it to fit the screen of the device. This is great for two reasons:
You set the resolution that you want in the constructor of your game object in the XNA game. I asked for the lowest resolution:
// Pre-autoscale settings.
graphics.PreferredBackBufferWidth = 240;
graphics.PreferredBackBufferHeight = 400;
I had to do some fiddling with the display to make the buttons work (you can find out more here) but the result was a physics display that looked lovely (and only a tiny bit blurred).
If you want to get your hands on some ready made 3D physics (with very generous licensing terms) then you should head over to BEPU.
If you want to speed up your XNA game on Windows Phone (or make it future proof as far as resolution is concerned) then you should start using the settings above.
Spent some of today converting an old XNA version of Pelmanism to run on Windows Phone 7. It was actually very easy, particularly once I started using the gesture support in XNA 4.0 With that I could just pick up tap events and use them in the program to select matching tiles.
At the moment the game uses 50 different images which I had originally scaled for an Xbox 360. This gave me a game size of 16Mb, which is quite large for Windows Phone game. But it downloaded to the device and ran quite happily. I’ve resized the pictures now and taken 10M off the size.
Next step is to use Flickr images from the new FlickrNet API that makes it easy to pull images onto the phone.
Sometimes you get a file from the internets, or in an email, which you actually trust. Thing is, Windows doesn’t. This can result in fun and games when you try to use this file or, if it is an archive, files from the archive.
As an example, I downloaded the TouchGestureSample from the Creators Club and I don’t want any messages about un-trusted files in Visual Studio 2010.
Solving this is actually quite easy (and best done before you remove the files from the archive). Right click on the item and then click Unblock to say that you trust this file.
(of course, if you do this with dangerous files it might not have a happy ending)
It is often very useful to find out what your programs are doing. You can put breakpoints into your code, but sometimes you just want print messages. If you are writing Windows Phone apps this is very easy, but it doesn’t use the Console.WriteLine that you might be used to. You can get messages from your Windows Phone program (even when it is running in the device) by using:
System.Diagnostics.Debug.WriteLine ("Your Message Here ");
The output appears in the Output window in Visual Studio 2010 (remember to ask it to show you output from the Debug stream). The best way to control debug output is to use conditional compilation to switch your debug statements on and off:
// Put this at the top of the program to turn debugging on
#define Debug…
#ifdef Debug
System.Diagnostics.Debug.WriteLine ("Debug Message Here ");
#endif
Now it can be told. The tool is for making holes in network cables so you can attach a Vampire tap to them. In the olden days Ethernet networks were made of a single thick piece of co-axial cable (the same stuff we use to connect TVs to aerials). This had a terminator at both ends and the way you connected a station to the network was to drill a hole in the side of the cable and push a pin into the central conductor. These connectors got the name of “vampire taps” for obvious reasons.
Getting the hole wrong (too big or too deep) was bad, as you only had the one cable for your entire network. So we used to use a device with a drill bit which had been cut to just the right diameter and depth in the tool you see above.
This was in the “Good Old Days” of networking, 10BASE5 style (this means 10MBits/second, baseband signals and 500 metre maximum segment length). Nowadays we are up to 100GBits/second on some networks. That is 10,000 times faster.
The tool has rattled around in my desk for a while and I probably should get rid of it.
Having said all that, it does remind me of a Veroboard track cutter. I used to have one of those too. It’s a tool which lets you make breaks in copper tracks on circuit boards by cutting through them with a drill bit. So, I reckon that Dave G is a winner here and if he wants to drop by he can have is Windows Phone lanyard.
Nice building in Hull today.
If you have an internet enabled phone and want the cheapest way to get on-line with it you really should take a look at Tesco Mobile. These folks will send you a free pay as you go sim (it costs 99 pence to buy in the store) and you can put credit on it in all the usual ways. You can also have a 2 pounds a week “unlimited use” network connection for your phone. In this case I think “unlimited” means 500 megs in the week, which is OK unless you start streaming “Deal or No Deal” to it. But then again, why would you want to do that?
It does mean that you can have a fully working internet phone for around 8 pounds a month, which has got to be good value. I popped one of these into my Windows Phone and it works a treat. The network is actually provided by O2, which may or may not be good news depending on where you live.
So, what was this used for?
Close up of the pointy end
I found this in my drawer today. Not used it for a while. I’ve got a Windows Phone Lanyard (tastefully printed with a Windows Phone logo all along its length) to give to the first person to come to my office in Hull and tell me what is and what we used to use it for.
A clue, it is not directly related to phones as such…
Rob Miles is technology author and educator who spent many years as a lecturer in Computer Science at the University of Hull. He is also a Microsoft Developer Technologies MVP. He is into technology, teaching and photography. He is the author of the World Famous C# Yellow Book and almost as handsome as he thinks he is.
Begin to Code with JavaScript is now available for purchase and download. You can find it here