APPENDIX BZune Development QuickReference Guide

This appendix shows you how to accomplish many different effects outside the context of more detailed examples.

Animation

To animate a sprite, load a sprite sheet and change the source rectangle over time using a method to calculate the source rectangle.

private void UpdateSourceRect() {     int width = _texture.Width / _numFrames;     int height = _texture.Height;     int frameOffset = _currentFrameIndex * width;     _sourceRect.X = frameOffset;     _sourceRect.Y = 0;     _sourceRect.Width = width;     _sourceRect.Height = height; }

Sprite animation is covered in Chapter 3.

Input Handling

Input handling is made much easier through the use of an input state component. You can find such a component ...

Get Zune Game Development Using XNA 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.