O'Reilly logo

Zune Game Development Using XNA 3.0 by Dan Waters

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

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 ...

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