WP7-3: The first Windows Phone application

Source: Internet
Author: User


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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.