Create a Windows Phone 7 puzzle game with source code

Source: Internet
Author: User
Tags visual studio 2010

Introduction

Now we use Windows Phone 7 to create a puzzle game that uses the Silverlight and XNA framework audio API features.

 

Getting started

 

Install WP7 tools

Install vs 2010

The installer automatically downloads and installs the required components.

If you want to use Expression Blend 4 WP7 extension, download and install Expression Blend.

After the installation is complete, restart Visual Studio 2010.

 

Game Interface

This is the main user interface ApplicationPage. This is the default code when you create a new Windows Phone application.

 

 

PageOrientation

One of the most significant impacts of a Windows Phone application hosting application is how to configure the layout direction with ApplicationPage, which has a configurable attribute named SupportedOrientations. The enumerated value can be landscape screen or PortraitOrLandscape. Assign it a value, whether in XAML or code, we can control how the application can change.

SecurityCritical is a property that is familiar to most Silverlight developers.

Please note that this is Silverlight security and is not specific to Windows Mobile Phones.

 

<TextBlock Visibility="{Binding ElementName=Page, Path=PageOrientation,     Converter={StaticResource OrientationToVisibilityConverter}, ConverterParameter= Landscape}" .../>
 
public object Convert(object value, Type targetType, object parameter, CultureInfo culture){var orientation = (PageOrientation)value;string showWhenOrientation = parameter.ToString().ToLower();bool show = false;switch (orientation){case PageOrientation.Portrait:case PageOrientation.PortraitDown:case PageOrientation.PortraitUp:show = showWhenOrientation == "vertical";break;case PageOrientation.Landscape:case PageOrientation.LandscapeLeft:case PageOrientation.LandscapeRight:show = showWhenOrientation == "landscape";break;}return show ? Visibility.Visible : Visibility.Collapsed;}

Use the XNA Framework audio API

I was pleasantly surprised that we could easily use the XNA framework to play sound effects. Real-time playback is required. Warning, but it has a picky format. I found that only WAV Files in PCM format are supported. I used GoldWave to save all audio in PCM format. For long clips, MP3 makes more sense, but you need to use the MediaElement control.

The following excerpt shows all sound effects in the Code definition in MainPage. xaml. cs:

 

readonly SoundEffect footStepSoundEffect = SoundEffect.FromStream(TitleContainer.OpenStream("Audio/Footstep.wav"));
 
 
Now, due to the time relationship, we will analyze the subsequent implementation methods and related technologies. However, all source code will be released this time.
This article synchronously published to codewp7 halogen surface network wp7 Development Forum: http://www.codewp7.com/forum.php? Mod = viewthread & tid = 123 & extra =

Click here for the source code

 

 

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.