O'Reilly logo

Microsoft XNA 4.0 Game Development Cookbook by Luke Drumm

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dragging, dropping, and sliding

If you're writing a game for a platform that has either touch or mouse support, then offering the ability for players to drag, drop, and slide elements around the screen can be a surprisingly compelling motivation to play in and of itself.

Getting ready

This recipe requires a selection of 100 by 100 pixel images to form both the background areas and the foreground draggable items. In my example, I created a blank, white texture named "block" for the background and a series of simple, white-lettered textures for the draggable item textures, as shown in the following illustration:

Getting ready

How to do it...

To start dragging and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required