Windows Phone 7 Sensors with XNA

Computing and Software Systems        UW Bothell  

Projects Home

CS1 Workbook

XNA & Windows Phone 7

XGA: XNA Game-Themed Assignments
XGA Latest Release
XGA Details

XGC1: XNA Game-Themed CS1
XGC1 Latest Release
XGC1 Details


Releated Publications
Peer Reviewed

Windows Phone 7 Sensors and XNA
Windows Phone 7 Sensors and XNA

Release 1.0 (XNA V4.0)


This tutorial set is designed for audiences where:

"You have worked with the XNA Framework API and you are interested in programming with sensors on the Windows Phone 7 device."

More specifically, the tutorials are designed for faculty members in higher education who have worked with XNA and are interested in including Windows Phone 7 (WP7) as part of their courses or research programs. The tutorials are designed to illustrate the details of working with the Wp7 sensors. It is assumed that faculty members will have their distinct requirements for abstraction. The tutorials do not attempt to wrap or hide the sensor APIs.

The tutorial does not attempt to address any application-level issues (e.g., game-design, game-play), or general issues concerning programming with the XNA Framework. General developers in the XNA community may find the tutorials to be helpful as an initial guide to working with the sensors on the Windows Phone 7 device.

The Tutorials:

  • Development Environment: Here are the detailed step-by-step guide for setting up the environment to programWP7 devices.
    • WP7 Development Tool access/download.
    • Windows Phone Market place registration details.
    • Unlocking your phone for development.
    • IDE download and setup.

  • XNA with WP7 Sensors: The following are 5 simple tutorials focus on demonstrating how to work with respective sensors on the phone. The tutorials are loosely related. However it is important to start with the first tutorial on pinch zoom and touch panel because all of the examples require user input and thus require knowledge in decoding user touches or gestures.
    Pinch Image Pinch Zoom and Touch Panel: the phone touch screen
    • Touch panel: press, move.
    • Gesture: Tap, Drag, Pinch, Flick, etc.
    Emulator: supports all functionality except pinch zoom.
    Orientation Image Orientation: portrait vs. landscape orientations
    • Application locks orientation vs. user phone control.
    • Portrait, left/right landscape modes.
    Emulator: supports all functionality.
    Accelerometer Image Accelerometer: the X/Y/Z accelerometers
    • Thread-save programming interface.
    • Range and values of accelerometer readings.
    Emulator: no support for accelerometer. This demo does not work on the emulator.
    Camera Image The camera: camera and photo chooser tasks
    • Camera and Photo Choose as separate Tasks.
    • Import image and convert to Texture2D.
    Emulator: supports all functionality. The camera on the emulator does not take actual photographs.
    GPS Image The GPS: GPS receiver, geo-position, and resolving civil addresses
    • Receiver setup.
    • Triggered events.
    • Civic address resolution (future).
    Emulator: no support for GPS. This demo does not work on the emulator.
    BT Image Bluetooth: Not supported in First WP7 Release.


  • A Simple Library: A very simple library design to hide drawing and font-output details from the above tutorials. Here is the source code to the library.
    Library Image
    • Images hierarchy: simple image with size control: selectable, bounceable, and, zoomable. Selection and zooming supports arbitrary reference position.
    • Fonts: simple output of message
    • Vibrate, Song, SoundEffect

References and Credits

Useful WP7 Reference sites:

Useful XNA Reference sites:


Kelvin Sung
Computing and Software Systems
University of Washington, Bothell
Project home page: The Game-Themed Introductory Programming Project.

Microsoft Logo This work is supported in part by Microsoft Research under the Computer Gaming Curriculum in Computer Science RFP, Award Number 15871 and 16531, and Microsoft Higher Education..

The Imagine Cup Game Design round 1 deadline is Oct 15th. Imagine Cup Game Design competition is an opportunity for your students get an amazing game design and development experience (plus an opportunity for a free trip and prizes).  See for details.

Microsoft Logo This work is supported in part by a grant from Microsoft Research under the Computer Gaming Curriculum in Computer Science RFP, Award Number 15871 and 16531.

UWB Home 18115 Campus Way NE
Bothell, WA 98011-8246
(425) 352-5000
(425) 352-5303 (TDD)
University of Washington Bothelll
Copyright 2008, UWB. All rights reserved.
Comments to Kelvin Sung:
Last Modified: September 29 2010 21:34:59. KS