Home > XBOX > Video Game Console > XBOX 360 E User Guide

XBOX 360 E User Guide

Here you can view all the pages of manual XBOX 360 E User Guide. The XBOX manuals for Video Game Console are available online for free. You can easily download all the documents as PDF.

Page 191

Step 3: Load the X ACT Project through the Content Pipeline
You’ve just created and saved an XACT project that contains two wave files. The next step is to load this XACT
project into the Content Pipeline:> Return to Visual C# 2005 Express Edition, and make sure your game project is loaded. If it isn’t, click Open Project on the File menu, and browse to your project. 
> Right-click on the Content\Audio folder in the Solution Explorer, select Add, and then select Existing Item. Using the dialog box that...

Page 192

Step 4: Play Sounds Using the Audio API
Access the sounds you wish to play in your game via a Cue object, which you can get by calling GetCue or play
directly by calling PlayCue.In this tutorial, we do both. For our looping engine sound, we call GetCue to get and hold the engine cue, and
pause and resume the cue as our engines turn on and off when the user pulls the trigger. When the player
presses  1to warp, we play the hyperspace sound by calling PlayCue.
Find the UpdateInput method. Modify it to look...

Page 193

Many things are happening here. Here’s a breakdown of what we’re doing:
//Cue so we can hang on to the sound of the engine
Cue engineSound = null; The Cue represents an instance of a sound. In this case, this Cue represents the sound of our engines when
we pull the right trigger.
188
Xbox 360™Han dbook

}
else if (engineSound.IsPaused)
{ engineSound.Resume();
}
}
else
{ if (engineSound != null && engineSound.IsPlaying)
{engineSound.Pause();
}
}
//in case you get lost, press  Ato warp back to the center...

Page 194

This code manages the engine sound. Since we enter this code once every frame, we have to make sure we
don’t continually try to play the same sound—we only want to modify the state of the Cue if there’s a change,
such as the trigger being released. This code uses GetCue the first time through the loop to ready the Cue to
play and to play it if the trigger is down. From that point forward, each release of the trigger calls Pause and halts playback of the Cue. Subsequently
pulling the trigger again will...

Page 195

Congratulations!
At this point, you have a spaceship that floats in 3-D space, that moves around when you use your Xbox 360
Controller, and that makes sounds and gives you feedback in your controller. You have created the very beginnings
of a 3-D game using XNA Game Studio Express, and you’re just getting started. There’s so much more to explore!
Ideas to Expand
If you’re ready to go further with this sample, try a few of these ideas:> Use some of the advanced runtime parameter control functionality of...

Page 196

191
Welcome to XNA™

{graphics = new GraphicsDeviceManager(this);
content = new ContentManager(Services);
}
AudioEngine audioEngine;
WaveBank waveBank;
SoundBank soundBank;
protected override void Initialize()
{ audioEngine = new AudioEngine(“Content\\Audio\\MyGameAudio.xgs”);
waveBank = new WaveBank(audioEngine, “Content\\Audio\\Wave Bank.xwb”);
soundBank = new SoundBank(audioEngine, “Content\\Audio\\Sound Bank.xsb”);
base.Initialize();
}
//3d model to draw
Model myModel;
protected override void...

Page 197

192
Xbox 360™Han dbook

this.Exit();
//Get some input
UpdateInput();
//update audioEngine
audioEngine.Update();
//add velocity to current position
modelPosition += modelVelocity;
//bleed off velocity over time
modelVelocity *= 0.95f;
base.Update(gameTime);
}
//Cue so we can hang on to the sound of the engine
Cue engineSound = null;
protected void UpdateInput()
{ //get the gamepad state
GamePadState currentState = GamePad.GetState(PlayerIndex.One);
if (currentState.IsConnected)
{//rotate the model using...

Page 198

193
Welcome to XNA™

//set some audio based on whether we’re pulling trigger
if (currentState.Triggers.Right > 0)
{if (engineSound == null)
{engineSound = soundBank.GetCue(“engine_2”);
engineSound.Play();
}
else if (engineSound.IsPaused)
{ engineSound.Resume();
}
}
else
{ if (engineSound != null && engineSound.IsPlaying)
{engineSound.Pause();
}
}
//in case you get lost, press  Ato warp back to the center
if (currentState.Buttons.A == ButtonState.Pressed)
{ modelPosition = Vector3.Zero;
modelVelocity =...

Page 199

194
Xbox 360™Han dbook

float aspectRatio = 640.0f / 480.0f;
protected override void Draw(GameTime gameTime)
{graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
//Copy any parent transforms
Matrix[] transforms = new Matrix[myModel.Bones.Count];
myModel.CopyAbsoluteBoneTransformsTo(transforms);
//Draw the model; a model can have multiple meshes, so loop
foreach (ModelMesh mesh in myModel.Meshes)
{//This is where the mesh orientation is set, as well as our camera and projection
foreach (BasicEffect...

Page 200

Xbox 360™Han dbookThe Official User ’s Guide

12 :
What Is Old
Is New Again
Protected by copyright. Unauthorized or unlawful copying or downloading expressly prohibited. 
Start reading XBOX 360 E User Guide

Related Manuals for XBOX 360 E User Guide

All XBOX manuals