Skip to Content
Professional Windows® Phone 7 Game Development: Creating Games using XNA Game Studio 4
book

Professional Windows® Phone 7 Game Development: Creating Games using XNA Game Studio 4

by Chris G. Williams, George W. Clingerman
February 2011
Beginner to intermediate content levelBeginner to intermediate
552 pages
12h 40m
English
Wrox
Content preview from Professional Windows® Phone 7 Game Development: Creating Games using XNA Game Studio 4

Chapter 5. Give Me Your Input

WHAT'S IN THIS CHAPTER?

  • Building your own input management system

  • Mapping multiple sources of control input to the same actions

When developing games for multiple target platforms, you will quickly run into scenarios where your game requires several different ways to perform the same action based on the limitations of the individual platforms. The opposite can happen when you're developing a single-platform game. As your game gets progressively more screen states (and correspondingly more complex), you may find yourself needing to map different game actions to the same button, based on the active screen.

No matter which of these situations you find yourself in, there is a very simple answer. As described in this chapter, a properly designed input management system provides the freedom to map any number of actions to a single control and to map multiple controls to a single action.

BUILDING THE INPUT MANAGEMENT SYSTEM

The first step when creating an input management system is to disconnect individual actions from the control inputs that cause them. This allows you to map multiple input types to a single action and also makes it easier to change mappings (if necessary) from one screen to the next.

Input.cs

The purpose of the Input class is to store information about each input type that you will define in your game. This class will be used in the Inputs collection in the GameInput class defined later in this chapter.

Note

The complete code for this project is available ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XNA Game Studio 4.0 Programming: Developing for Windows® Phone 7 and Xbox 360®

XNA Game Studio 4.0 Programming: Developing for Windows® Phone 7 and Xbox 360®

Tom Miller, Dean Johnson

Publisher Resources

ISBN: 9780470922446Purchase book