Windows Phone 7 Game State Management using XNA
Not so long ago I wrote a Puzzle game for Windows Phone 7 using XNA. The game was really simple and had no menu or state management. Luckily, I recently stumbled upon a sample on MSDN that describes the basics of implementing game state management using XNA.
To try things out a bit more I modified my existing puzzle game and included the sample game state management code. The results are pretty amazing!
Here’s how my Puzzle Game for Windows Phone 7 looks like now:
I described in detail how I built my puzzle game application in an article called Writing a Puzzle Game for Windows Phone 7 using XNA. Try checking it out, I hope you find it interesting
Microsoft Advertising SDK for Windows Phone 7
I recently stumbled upon the Microsoft Advertising SDK for Windows Phone 7. At the client side, it provides a control called AdControl that retrieves banner information based on the specified ApplicationId and AdUnitId. In order to use the Microsoft Advertising’s ad delivery system, you first need to create a Microsoft pubCenter account.
Here’s some information extracted from the help file included in the SDK:
The Microsoft Advertising SDK for Windows Phone 7 provides an AdControl that you can use to publish advertisements in Windows Phone 7 applications. The Microsoft Advertising AdControl communicates with Microsoft servers that deliver ads. When these servers return ads to the AdControl, the AdControl will render the ads within your Windows Phone 7 application.
In order to use the Microsoft Advertising’s ad delivery system, you first need to create a Microsoft pubCenter account. Microsoft pubCenter is an advertising publisher management system that enables you to create ad placements and collect advertising revenue. Once you create an account, you will register your mobile applications by using Microsoft pubCenter. When a Windows Phone 7 application is registered with Microsoft pubCenter it will receive a unique mobile application identifier (ApplicationId).
When a mobile application displays a window, the application can define a space within the window for the presentation of advertisements. Each ad placement that is presented is called an ad unit. You will define and create mobile ad units by using Microsoft pubCenter, and each mobile ad unit will be assigned a unique ad unit identifier (AdUnitId).
The ApplicationId and the AdUnitId are required for your Windows Phone 7 application to request ads from Microsoft Advertising’s ad delivery system. The ApplicationId and the AdUnitId identify the ad unit that is delivered to a Windows Phone 7 application and the publisher that will receive credit for displaying the ad unit.
It takes only a few easy steps to register with Microsoft pubCenter, create ad units, manage revenues, and integrate the Microsoft Advertising Mobile AdControl for Windows Phone 7 into your application.
Sounds fairly simple but not everything can be perfect in a first release. The first problem I found was that the pubCenter Registration and Payment will only be available for publishers from the United States. So to be eligable for payments one must for example have a valid US address and a valid Tax Information Number (TIN) if the publisher is a business entity. As I’m not based in the US, I haven’t tried this yet. But based on what I’ve read in the documentation, using the AdControl in a Windows Phone 7 application seems fairly easy.
Here are some C# and XAML snippets:
The following C# code instantiates a new AdControl and sets mandatory targeting parameters.
AdControl ctrl = new AdControl();
ctrl.ApplicationId = "testapplication";
ctrl.AdUnitId = "testadunit";
this.ContentGrid.Children.Add(ctrl);
The following C# code instantiates a new AdControl with manual ad rotation.
string applicationId = "testapplication";
string adUnitId = "testadunit";
bool isAutoRotation = false;
AdControl ctrl = new AdControl(applicationId, adUnitId, AdModel.Contextual, isAutoRotation);
ctrl.Width = 480;
ctrl.Height = 80;
this.ContentGrid.Children.Add(ctrl);
The following XAML instantiates a new AdControl with mandatory targeting parameters.
<Grid xmlns:adctl="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI" Grid.Row="1">
<adctl:AdControl Height="80" Width="480" AdUnitId="Test" ApplicationId="Test" AdModel="Contextual" />
</Grid>
I’m looking forward for these tools to be available in Europe so I can try them out.
How to retrieve a list of installed applications using .NETCF
In this short post I’d like to demonstrate how to retrieve a list of installed applications on a Windows Mobile device using OMA Client Provisioning. First you need to add a reference to the Microsoft.WindowsMobile.Configuration assembly. To retrieve the list we need to process a specific configuration (UnInstall Configuration Service Provider) using the ConfigurationManager.ProcessConfiguration method. The configuration is described in an XML and the response to this will also be described in XML
To query the device we process this configuration:
<wap-provisioningdoc>
<characteristic-query type="UnInstall"/>
</wap-provisioningdoc>
The query above will only return installed application that can be uninstalled. The device would then respond with something like this:
<wap-provisioningdoc>
<characteristic type="UnInstall">
<characteristic type="Microsoft Application#2">
<parm name="uninstall" value="0"/>
</characteristic>
<characteristic type="Microsoft Application#1">
<parm name="uninstall" value="0"/>
</characteristic>
<characteristic type="Demo Home Screen">
<parm name="uninstall" value="0"/>
</characteristic>
</characteristic>
</wap-provisioningdoc>
And here’s how to accomplish this task using .NETCF and C#
var doc = new XmlDocument();
doc.LoadXml(@"<wap-provisioningdoc><characteristic-query type=""UnInstall""/></wap-provisioningdoc>");
doc = ConfigurationManager.ProcessConfiguration(doc, true);
var nodes = doc.SelectNodes("wap-provisioningdoc/characteristic[@type='UnInstall']/characteristic/@type");
foreach (var node in nodes.Cast<XmlNode>())
{
Trace.WriteLine(node.InnerText);
}
I hope you found this useful.