Home Page Icon
Home Page
Table of Contents for
I. The Beginning
Close
I. The Beginning
by Adam Dawes
Windows Phone 7 Game Development
Copyright
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
This Goal of This Book
Who This Book Is For
Chapter Overview
I. The Beginning
1. Windows Phone and .NET
1.1. Looking Closely at Visual Studio Development for Windows Phone
1.1.1. Language Choices
1.1.2. IDE Features
1.1.2.1. Emulators
1.1.2.2. Silverlight Page Designer
1.1.2.3. Breakpoints
1.1.2.4. Debug Output
1.2. Windows Phone Platform
1.2.1.
1.2.1.1. Screen Hardware
1.2.1.2. Hardware Buttons
1.2.1.3. Processors
1.2.1.4. Graphics Hardware
1.2.1.5. Location and Orientation
1.2.1.6. Cooperation with the Device
1.3. Using Visual Studio for Windows Phone Development
1.3.1. Installing Visual Studio
1.3.2. Creating a Windows Phone Project
1.3.2.1. Project Templates
1.3.3. Designing a Page
1.3.4. Running the Application
1.3.5. Running on a Real Device
1.3.5.1. Registering the Device
1.3.5.2. Deploying to the Device from Visual Studio
1.3.6. Debugging
1.3.6.1. Breakpoints
1.3.6.2. Debug Output
1.3.7. Getting Help
1.3.7.1. MSDN
1.3.7.2. Search Engines
1.3.7.3. Microsoft's Windows Phone Developer Center
1.3.7.4. Community Sites
1.4. Windows Phone Game Development
1.4.1. Suitable Games
1.4.2. Selecting an Application Framework
1.4.2.1. XNA
1.4.2.2. Silverlight
1.5. Welcome to the World of Windows Phone Development
II. XNA
2. Getting Started with XNA
2.1. What Is XNA?
2.2. Your First XNA Project
2.2.1. Creating the Project
2.2.2. Adding Some Content
2.2.3. Displaying the Graphic
2.2.4. Moving the Graphic
2.2.5. Examining the Solution in More Detail
2.2.5.1. The Game Project
2.2.5.2. The Content Project
2.3. Sprites in Detail
2.3.1. Supported Graphic Formats
2.3.2. Scaling
2.3.2.1. Using a Uniform Scaling Factor
2.3.2.2. Using a Non-uniform Scaling Factor
2.3.2.3. Using a Destination Rectangle
2.3.3. Rotation
2.3.4. Tinting
2.3.5. Partial Image Rendering
2.3.6. Layer Depth
2.3.7. Sprite Transparency
2.3.7.1. Color Key Transparency
2.3.7.2. Alpha Channel Transparency
2.3.8. Alpha Tinting
2.4. Useful Sprite Effects
2.4.1. Setting a Background Image
2.4.2. Fading to Black
2.4.3. Fading between Images
2.5. Displaying Text
2.5.1. Font Support
2.5.2. Creating SpriteFont Objects
2.5.3. Displaying Text
2.6. Other Graphics Options
2.6.1. Rendering in Full Screen Mode
2.6.2. Supporting Portrait and Landscape Orientations
2.6.2.1. Using Portrait Orientation
2.6.2.2. Using Landscape Orientation
2.6.2.3. Allowing Landscape and Portrait Orientations
2.6.3. Graphic Scaling
2.6.4. Suppressing Drawing
2.7. Experiment and Play with XNA
3. Creating a Game Framework
3.1. Designing the Game Framework
3.1.1. The GameObjectBase Class
3.1.2. The SpriteObject Class
3.1.3. The TextObject Class
3.1.4. The GameHost Class
3.1.5. The GameHelper Class
3.2. Using the Game Framework
3.2.1. Referencing the GameFramework Project
3.2.2. Setting Inheritance for the Main Game Class
3.2.3. Creating Derived SpriteObject Classes
3.2.3.1. The BoxObject Class
3.2.3.2. The BallObject Class
3.2.4. Adding Game Objects to the Game Host
3.2.5. Removing Objects from the Game Host
3.2.6. Overriding Object Properties
3.3. Benchmarking and Performance
3.3.1. The BenchmarkObject Class
3.3.2. Using BenchmarkObject
3.3.3. Performance Considerations
3.3.3.1. Texture Loading
3.3.3.2. Creating and Destroying Objects
3.3.3.3. Using for and foreach Loops
3.4. Game in Focus: Cosmic Rocks (Part I)
3.4.1. Designing the Game
3.4.2. Creating the Graphics
3.4.3. Creating the Game Objects
3.4.3.1. The RockObject Class
3.4.3.2. The SpaceshipObject Class
3.4.3.3. The ParticleObject Class
3.4.3.4. The StarObject Class
3.4.4. Running the Game
3.5. Creating XNA Games
4. User Input
4.1. Using the Touch Screen
4.1.1. Reading Raw Touch Data
4.1.1.1. The Life and Times of a Touch Point
4.1.1.2. Finding a Touch Point's Previous Location
4.1.1.3. Touch Panel Capabilities
4.1.1.4. Working with Rotated and Scaled Screens
4.1.2. Reading Input Using the Touch Gestures
4.1.2.1. Enabling the Gestures
4.1.2.2. Processing Gestures
4.1.2.3. Tap and DoubleTap
4.1.2.4. Hold
4.1.2.5. VerticalDrag, HorizontalDrag and FreeDrag
4.1.2.6. Flick
4.1.2.7. Pinch
4.1.2.8. Working with Rotated and Scaled Screens
4.1.2.9. Experimenting with the Gestures API
4.1.3. Sprite Hit Testing
4.1.3.1. Bounding Box Hit Tests
4.1.3.2. Rectangular Hit Tests
4.1.3.3. Elliptical Hit Tests
4.1.3.4. Building the Hit Tests into the Game Framework
4.1.3.5. Retrieving the Objects at a Hit Location
4.1.3.6. Hit Testing Example Projects
4.1.4. Initiating Object Motion
4.1.4.1. Dragging Objects
4.1.4.2. Flicking Objects
4.1.5. Finger-Friendly Gaming
4.2. Reading the Keyboard and Text Input
4.2.1. Using a Hardware Keyboard
4.2.1.1. Direct Keyboard Polling
4.2.1.2. Checking for Key Pressed and Key Released States
4.2.2. Prompting the User to Enter Text
4.3. Reading the Accelerometer
4.3.1. Initializing the Accelerometer
4.3.2. Using the Accelerometer Data
4.3.3. Simulating the Accelerometer in the Emulator
4.4. Game in Focus: Cosmic Rocks (Part II)
4.4.1. Making the Player's Ship Shoot
4.4.1.1. Rotating the Ship to Face a Point
4.4.1.2. Firing a Bullet
4.4.2. Making the Player's Ship Move
4.4.3. Implementing Hyperspace
4.5. Considering Input Design
5. Sounding Out with Game Audio
5.1. Sound Effects and Music
5.2. Playing Sound Effects
5.2.1. Adding Sound Effects to your Project
5.2.2. Playing the Sound Effects
5.2.3. Integrating Sound Effects into the Game Framework
5.2.4. Sound Effect Instances
5.2.5. Other Sound Effect Properties
5.2.6. Obtaining Sound Effects for your Game
5.2.7. An Interactive Example
5.3. Playing Music
5.3.1. To Play or Not To Play
5.3.2. Adding Music to your Project
5.3.3. Playing the Music
5.4. Game in Focus: Cosmic Rocks (Part III)
5.5. Make Some Noise
6. Drawing with Vertices and Matrices
6.1. A New Approach to Drawing
6.1.1. Matrix-Based Positioning
6.1.2. Abstract Coordinate System
6.1.3. Drawing Primitives
6.1.4. Textures
6.1.5. XNA is a State Engine
6.2. Creating our First Vertex Rendering Project
6.2.1. Setting Up the Environment
6.2.2. Rendering the Object
6.2.3. Moving the Object
6.2.4. Adding some Sparkle
6.3. Tinting Objects
6.4. Understanding Matrix Transformations
6.4.1. Setting the Identity Matrix
6.4.2. Applying Translation Transformations
6.4.3. Applying Rotation Transformations
6.4.4. Applying Scaling Transformations
6.4.5. Applying Multiple Transformations
6.4.5.1. Rotating Objects
6.4.5.2. Scaling Objects
6.4.5.3. Applying Multiple Transformations in XNA
6.4.6. Specifying Vertex Positions
6.4.7. Drawing Multiple Objects at Different Positions
6.5. Drawing Primitives
6.5.1. Drawing Lines
6.5.2. Drawing Triangles
6.5.3. Drawing Points
6.6. Applying Textures
6.6.1. Loading Graphics
6.6.2. Setting the Active Texture
6.6.3. Applying the Texture to an Object
6.6.4. Preparing the Effect for Texture Mapping
6.6.5. Configuring the Sampler State
6.6.5.1. Updating the Sampler State
6.6.5.2. Texture Addressing Modes
6.6.5.3. Texture Filtering
6.6.6. Supported Texture Image Formats
6.6.7. Using Different Textures Within the Same Draw Call
6.7. Using Transparency and Alpha Blending
6.7.1. Enabling and Disabling Alpha Blending
6.7.2. XNA's Built-In Blend States
6.7.2.1. Opaque
6.7.2.2. AlphaBlend
6.7.2.3. Additive
6.7.3. Creating Custom Blend States
6.7.4. Object Transparency
6.8. Handling Orientations
6.9. Graphic Scaling
6.10. Integration into the Game Framework
6.10.1. The MatrixObjectBase Class
6.10.1.1. Object Transformation
6.10.1.2. Object Rendering
6.10.2. Updates to the GameHost Class
6.10.3. Using the Game Framework for Matrix Rendering
6.11. Enter the Matrix
7. The World of 3D Graphics
7.1. Perspective Projection
7.1.1. The Viewing Frustum
7.1.2. Defining the Viewing Frustum in XNA
7.2. Rendering 3D Objects
7.2.1. Defining a 3D Object
7.3. The Depth Buffer
7.3.1. Enabling and Disabling the Depth Buffer
7.3.2. Clearing the Depth Buffer
7.3.3. Rendering Transparent Objects with the Depth Buffer
7.4. Hidden Surface Culling
7.5. Vertex and Index Buffers
7.5.1. Using Vertex Buffers
7.5.2. Using Indexed Vertices
7.5.3. Using Vertex Buffers and Indexing Together
7.6. Lighting
7.6.1. Lights and Materials
7.6.2. Types of Illumination
7.6.2.1. Ambient Light
7.6.2.2. Diffuse Light
7.6.2.3. Specular Light
7.6.3. Material Properties
7.6.3.1. Diffuse Material
7.6.3.2. Specular Material
7.6.3.3. Emissive Material
7.6.4. Light and Material Interaction
7.6.5. Using Multiple Lights
7.6.6. Reusing Lights
7.6.7. Types of Light Source
7.6.8. How XNA Calculates Light Reflections
7.6.8.1. Describing a Triangle's Face Direction
7.6.8.2. Calculating Normals
7.6.8.3. Surface Normals and Vertex Normals
7.6.9. Adding Lighting to Games
7.6.9.1. Enabling and Disabling Lighting
7.6.9.2. Light Configuration
7.6.9.3. Ambient Light
7.6.9.4. Specular Light
7.6.9.5. Emissive Light
7.6.9.6. The Standard Lighting Rig
7.6.9.7. Programmatic Calculation of Normals
7.7. Orthographic Projection
7.7.1. The Viewing Frustum
7.7.2. Defining the Orthographic Viewing Frustum in XNA
7.7.3. Isometric Projection
7.7.4. Pixel-Aligned Projection
7.8. Mastering the 3D World
8. Further 3D Features and Techniques
8.1. Importing Geometry
8.1.1. SketchUp
8.1.1.1. Creating 3D Objects in SketchUp
8.1.1.2. Exporting 3D Geometry
8.1.2. Importing Saved Geometry into XNA Projects
8.1.3. Rendering Imported Geometry
8.1.4. Adding Support into the Game Framework
8.1.5. The Google SketchUp 3D Warehouse
8.1.6. Importing Other File Formats
8.2. Working with the Camera
8.2.1. Camera Position and Orientation
8.2.2. Integrating Camera Support into the Game Framework
8.2.2.1. The Camera Class
8.2.2.2. Camera Positioning
8.2.2.3. The Camera Object in Action
8.2.3. Creating a Chase Cam
8.2.3.1. Adding the Paper Plane
8.2.3.2. Animating the Plane
8.2.3.3. Implementing the Chase Cam
8.2.3.4. Using the Chase Cam
8.3. Adding Fog
8.4. Adding a Skybox
8.4.1. Creating Skyboxes
8.4.2. Implementing the Skybox into the Game Framework
8.5. Particles
8.5.1. How Particles are Implemented
8.5.2. Billboarding
8.5.3. Adding Particle Support to the Game Framework
8.5.4. Creating Fire and Smoke
8.5.5. Vapor and Smoke Trails
8.5.6. Fairy Dust
8.6. Using Effect Objects
8.6.1. Effect Capabilities
8.6.2. AlphaTestEffect
8.6.3. DualTextureEffect
8.6.4. EnvironmentMapEffect
8.6.4.1. Preparing the Environment Map
8.6.4.2. Environment Map Properties
8.6.4.3. Rendering Untextured Objects with Environment Maps
8.6.5. SkinnedEffect
8.7. Mixing Sprite and Matrix Rendering
8.8. A Universe of Possibilities
9. Enhancing Your Game
9.1. Managing Game Settings
9.1.1. Class Structure
9.1.2. Setting and Retrieving Values
9.1.3. Displaying a Settings Screen
9.1.4. Creating the Settings User Interface
9.1.4.1. Opening the Settings Screen
9.1.4.2. Updating the Settings Values
9.1.4.3. Leaving the Settings Screen
9.2. Planning a Game's Navigation Model
9.3. Adding a High Score Table
9.3.1. Implementing the High Score Table
9.3.1.1. Defining Tables
9.3.1.2. Working with High Score Tables
9.3.1.3. High Score Entries
9.3.1.4. Clearing Existing High Scores
9.3.1.5. Loading and Saving Scores
9.3.1.6. Reading and Writing Files in Isolated Storage
9.3.2. Using the HighScore Classes in a Game
9.4. Reusing Game Components
10. The Application Life Cycle
10.1. The Effects of Losing Focus
10.2. Life Cycle Events
10.2.1. The Launching Event
10.2.2. The Closing Event
10.2.3. The Deactivated Event
10.2.4. The Activated Event
10.2.5. Handling the Life Cycle Events
10.2.6. Seeing the Events in Action
10.3. Persisting Session State
10.3.1. Controlling Serialization
10.3.2. DataContracts and Inheritance
10.3.3. Persisting Nonserializable Data
10.4. Tombstoning in the Game Framework
10.4.1. Setting up the GameHost Event Handlers
10.4.2. Preparing the Classes for Serialization
10.4.3. Persisting Content References
10.4.4. Automatic Storage and Retrieval of Game Objects in the State Dictionary
10.4.5. Identifying Specific Objects After Tombstoning
10.4.6. Game Initialization
10.4.7. Troubleshooting Serialization
10.5. Returning from the Grave
III. Silverlight
11. Getting Started with Silverlight
11.1. A Brief History of Silverlight
11.1.1. Windows Presentation Foundation
11.1.2. Silverlight
11.1.3. Silverlight on Windows Phone
11.2. Creating Silverlight Projects for Windows Phone
11.2.1. Choosing a Project Template
11.2.1.1. Windows Phone Application Template
11.2.1.2. Windows Phone Databound Application Template
11.2.1.3. Windows Phone Class Library Template
11.2.1.4. Windows Phone Panorama Application Template
11.2.1.5. Windows Phone Pivot Application Template
11.2.2. Working with Silverlight Projects
11.2.3. Examining the Solution in More Detail
11.2.3.1. The Project Structure
11.2.3.2. Project Images
11.2.3.3. The App.xaml File
11.2.3.4. The MainPage.xaml file
11.2.3.5. The Hidden Source Files
11.2.4. Referencing Other Projects
11.3. Exploring XAML
11.3.1. What Is XAML For?
11.3.2. The Silverlight Page Structure
11.3.3. XAML's Syntax
11.3.3.1. Starting Off with App.xaml
11.3.3.2. Moving On to MainPage.xaml
11.3.3.3. Returning to App.xaml
11.3.3.4. XAML Syntax Summary
11.4. Working with the Page Designer
11.4.1. Adding and Positioning Elements
11.4.2. The Document Outline Window
11.4.3. Using the Properties Window
11.4.4. Understanding Control Alignment
11.5. Colors and Brushes
11.5.1. Color Specifications
11.5.2. Brushes
11.5.2.1. SolidColorBrush
11.5.2.2. LinearGradientBrush
11.5.2.3. RadialGradientBrush
11.5.2.4. ImageBrush
11.5.3. Setting Colors in Code
11.5.4. Using Brushes Together
11.6. Exploring Silverlight
12. Silverlight Controls and Pages
12.1. The Silverlight Controls
12.1.1. Display Controls
12.1.1.1. TextBlock Controls
12.1.1.2. Image Controls
12.1.1.3. ProgressBar Controls
12.1.1.4. Ellipse and Rectangle Controls
12.1.1.5. Line, Polyline, and Polygon Controls
12.1.2. Interactive Controls
12.1.2.1. TextBox Controls
12.1.2.2. ListBox Controls
12.1.2.3. ComboBox Controls
12.1.2.4. CheckBox Controls
12.1.2.5. RadioButton Controls
12.1.2.6. Button Controls
12.1.2.7. ApplicationBar Controls
12.1.3. Layout Controls
12.1.3.1. Grid Controls
12.1.3.2. StackPanel Controls
12.1.3.3. Canvas Controls
12.1.3.4. ScrollViewer Controls
12.1.3.5. Border Controls
12.1.4. User Interface Design
12.2. Using Control Transforms and Projections
12.2.1. Using RotateTransform
12.2.2. Using ScaleTransform
12.2.3. Using SkewTransform
12.2.4. Using TranslateTransform
12.2.5. Using TransformGroups
12.2.6. Using CompositeTransform
12.2.7. Using Projection
12.3. Orientation
12.4. Running in Full Screen Mode
12.5. Multipage Projects
12.5.1. Adding New Pages to a Project
12.5.2. Navigating Between Pages
12.5.3. Passing Values When Navigating
12.5.3.1. Adding URI Query String Elements
12.5.3.2. Passing Values with the DataContext Object
12.6. Game On. . .
13. Gaming with Silverlight
13.1. Creating Sprites
13.1.1. Sprite User Control
13.1.2. Sprite Image Handling
13.1.3. Positioning the Sprite
13.1.4. Sprite Transformations
13.1.5. Adding Sprites to a Silverlight Page
13.1.6. Creating Sprites at Runtime
13.1.7. Sprite Examples
13.2. Sprite Movement
13.2.1. Procedural Animation
13.2.2. Storyboard Animation
13.2.2.1. Storyboard Features
13.2.2.2. Using Storyboards
13.2.2.3. Integrating Storyboard Support into the Sprite Control
13.2.2.4. Storyboard Raindrops
13.3. Silverlight Performance
13.3.1. Reading the Frame Rate Counters
13.3.1.1. Compositor Thread Frame Rate
13.3.1.2. GPU Surface Count
13.3.1.3. Fill Rate Counter
13.3.2. Using Cache Visualization
13.3.3. Viewing Redraw Regions
13.4. User Input
13.4.1. Control Events
13.4.1.1. Mouse Events
13.4.1.2. Manipulation Events
13.4.1.3. Event Bubbling
13.4.2. Touch Events
13.4.2.1. Single-Touch Input
13.4.2.2. Multitouch Input
13.4.3. Gestures
13.4.4. Accelerometer
13.5. Game in Focus: Diamond Lines, Part I
13.5.1. Sprite Configuration
13.5.2. Game Flow
13.5.3. Input Processing
13.5.4. Sprite Animation
13.6. Using Silverlight for Game Development
14. Enhancing Your Silverlight Games
14.1. Game Navigation
14.1.1. Defining the Navigation Flow
14.1.2. Redirecting Navigation
14.1.3. Implementing the Navigation Flow
14.1.4. Navigating Between Pages
14.1.5. Maintaining Game State
14.2. Game Settings
14.3. Creating a High Score Table
14.3.1. The High Score Table Classes
14.3.2. Instantiating the HighScores Object
14.3.3. Adding New Score Entries
14.3.4. Displaying the Scores
14.4. Playing Music and Sound Effects
14.4.1. Accessing the XNA Audio Library
14.4.2. Initializing the XNA Dispatch Timer
14.4.3. Playing Sound Effects
14.4.4. Playing Music
14.5. Application Life Cycle
14.5.1. Exploring Tombstoning Behavior in Silverlight
14.5.2. Storing and Restoring State
14.6. Game in Focus: Diamond Lines, Part II
14.6.1. Adding Game Navigation
14.6.2. Maintaining Game State
14.6.3. Tombstoning Support
14.6.4. Adding Game Settings
14.6.5. Implementing the Sound Effects
14.7. Gaming with Silverlight
IV. Distribution
15. Distributing Your Game
15.1. Testing Your Game
15.2. Trial Mode
15.2.1. Detecting Trial Mode
15.2.2. Purchasing the Full Version
15.2.3. Offering Promotional Upgrades
15.3. Submission Requirements
15.3.1. Content Policies
15.3.2. Application Requirements
15.3.3. Localization
15.3.4. Application Features
15.3.5. Reliability and Performance
15.3.6. Technical Information
15.3.7. Music and Sound
15.4. Preparing for Distribution
15.4.1. Setting the Assembly Information
15.4.2. Setting the Assembly Version
15.4.3. Setting the Project Properties
15.4.4. Setting the Manifest Properties
15.4.5. Providing Graphics Files
15.4.6. Compiling the Game
15.5. Selling or Giving Your Game for Free
15.6. Submitting Your Game to the Marketplace
15.7. Promoting Your Game
15.7.1. Capturing Your Game in Motion
15.7.2. Editing Your Video Clip
15.8. Go Create!
16. Running on Other Platforms
16.1. Running XNA Projects in Windows
16.1.1. Porting Projects to Windows
16.1.2. Using Conditional Compilation
16.1.3. Project Differences
16.1.4. Display Differences
16.1.4.1. Setting the Window Size
16.1.4.2. Using Full Screen Mode
16.1.4.3. Showing and Hiding the Mouse Cursor
16.1.5. Input Differences
16.1.5.1. Mouse Input
16.1.5.2. Gestures
16.1.5.3. Keyboard Input
16.1.5.4. GamePad Input
16.1.6. Isolated Storage
16.1.7. Application Life Cycle
16.1.8. Converting the Game Framework to Run on Windows
16.1.8.1. Storing and Retrieving Game Settings
16.1.8.2. Application Life Cycle Events
16.1.8.3. High Scores
16.1.8.4. Everything Else
16.1.9. Trial Mode
16.1.10. Distribution
16.1.11. Revisiting Some Example Projects
16.1.11.1. The FireAndSmoke Project
16.1.11.2. The VaporTrailTS project
16.1.12. Developing Games for Windows Phone 7 and Windows
16.2. Running Silverlight Projects in the Browser
16.2.1. Differences between Silverlight and Silverlight for Windows Phone
16.2.2. Converting Projects from Windows Phone 7
16.2.2.1. Creating a New Silverlight Project
16.2.2.2. Silverlight Navigation Model
16.2.2.3. Adding the Project Pages
16.2.3. Example Projects
16.2.3.1. Navigation
16.2.3.2. Diamond Lines
16.3. Let's Play. . .
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Introduction
Next
Next Chapter
1. Windows Phone and .NET
Part I. The Beginning
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset