As the 2nd course of hands on lab, this course is designed to be very classic. He developed a puzzle game that we are very familiar, to show you the simple game development process of phone7. The whole exercise is very smooth, except for the logic of the game itself (this part is really a pain point, I was trying to understand this part.CodeFinally, I gave up the game logic code.ProgramThe employee really cannot afford to hurt .), Other parts are relatively simple. It mainly includes the following parts:
1. The main purpose of unhandled exceptions is to prevent the application from crashing if there are unhandled exceptions in the application. You can handle an application_unhandledexception event in the app. XAML (similar to global. asax in Asp.net) file of the project. The error information is displayed on the errorpage.
On the errorpage, You need to place a textbox to display errors.
public partial class ErrorPage : PhoneApplicationPage
{
public ErrorPage ()
{
InitializeComponent();
}
public static Exception Ex;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ErrorText.Text = Ex.ToString();
base.OnNavigatedTo(e);
}
}
Modify the code in the application_unhandledexception event in APP. XAML. CS
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
}
e.Handled = true;
Error.Ex = e.ExceptionObject;
(RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Source =
new Uri("/Error.xaml", UriKind.Relative);
}
Result
2. The game logic & interface. The game logic and details are no longer recorded here. Some knowledge about phone7 is very common API calls, and the results
3. animation effect. the animation in silveright has already been done in blend in the first course. It is mainly a pre-prepared resource and can be loaded when used, we also need to learn more about Silverlight to understand its principles. (After you complete the puzzle, the picture will play an animation and rotate it in a circle)
4. State Storage
An isolatedstoragehelper class is implemented in the course, which is used to serialize the game status so that the game can be restored at the next time (commonly known as "ARCHIVE"). This section is also very common and requires in-depth content, refer to here