My brain makes things explode.
Posts tagged Zune
ZuneHD – Virtual D-Pad Component for XNA 3.1
May 16th
Just finished working on a pretty basic virtual d-pad for the Zune HD/XNA Framework 3.1. It’s really rough around the edges, and certainly isn’t optimized, but it works.
Download
Source
DPadHD.dll (Managed Library)
Description
A simple, kind of messy virtual d-pad for your ZuneHD games. You can feel free to add it to your games, with or without crediting me, just don’t distribute the D-Pad or modifications of it without at least giving word that it came from me. It’ll need a fair bit of optimization and editing before it’s ready for any game that you wish to distribute, however.
Features
Position can be configured
Works similarly to the default XNA input systems
Built as an XNA DrawableGameComponent
Usage Sample
dPadManager = new Segfault.DPadHD.DPadManager(this); dPadManager.Landscape = true; this.Components.Add(dPadManager);
Creating the system is easy. First, you create it as you would any other component. You can set whether or not you want to use it in Landscape mode (which merely rotates the inputs counter-clockwise – I assume a “back-button-to-the-right” landscape view) by setting a simple boolean value, and then you add the D-Pad Manager to the components list. It will update automatically, just as the XNA input managers do by default.
Its position can be set on screen with the following code:
dPadManager.Position = new Vector2(50.0f, 12.0f);
And finally, the state of the D-Pad’s four cardinal direction buttons can be checked by retrieving the current game state:
if (this.dPadManager.GetState().IsButtonDown(Segfault.DPadHD.DPadButton.Up)) pos.X += (gameTime.ElapsedGameTime.Milliseconds); if (this.dPadManager.GetState().IsButtonDown(Segfault.DPadHD.DPadButton.Down)) pos.X -= (gameTime.ElapsedGameTime.Milliseconds); if(this.dPadManager.GetState().IsButtonDown(Segfault.DPadHD.DPadButton.Left)) pos.Y -= (gameTime.ElapsedGameTime.Milliseconds); if (this.dPadManager.GetState().IsButtonDown(Segfault.DPadHD.DPadButton.Right)) pos.Y += (gameTime.ElapsedGameTime.Milliseconds);
Enjoy. :D
