Đang chuẩn bị liên kết để tải về tài liệu:
Microsoft XNA Game Studio Creator’s Guide- P18
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Microsoft XNA Game Studio Creator’s Guide- P18:The release of the XNA platform and specifically the ability for anyone to write Xbox 360 console games was truly a major progression in the game-programming world. Before XNA, it was simply too complicated and costly for a student, software hobbyist, or independent game developer to gain access to a decent development kit for a major console platform. | 488 MICROSOFT X N A GAME STUDIO CREATOR S GUIDE in a SoundEffect object. A SoundEffectInstance is created from this SoundEffect object which gives you the ability to loop pause and resume your individual sound effects. The firing audio is loaded into a SoundEffect object which is used later for playback whenever the B button is pressed. load and play background audio backgroundAudio Content.Load Song Audio telemetricBeep MediaPlayer.Play backgroundAudio MediaPlayer.IsRepeating true load and play engine as SoundEffectInstance for playback control engineSound Content.Load SoundEffect Audio engine0 engineinstance engineSound.Play VOLUME PITCH PAN LOOP load fire sound effect for playback later fireSound Content.Load SoundEffect Audio fire Lastly inside Update you can add this code to trigger the firing audio whenever the B button is pressed. This code will also allow your players to pause and resume the ship engine and telemetric beep whenever they press the center of the Zune pad. get new game pad states GamePadState gpCurrent GamePad.GetState Playerindex.One play fire sound at each new B button press event if gpCurrent.IsButtonDown Buttons.B gpPrevious.IsButtonUp Buttons.B fireSound.Play VOLUME PITCH PAN LOOP toggle engine audio pause and resume states for DPad.Down events if gpCurrent.Buttons.A ButtonState.Pressed gpPrevious.Buttons.A ButtonState.Released if engineinstance.State SoundState.Playing engineinstance.Pause MediaPlayer.Pause else engineinstance.Resume MediaPlayer.Resume store game pad state for next frame gpPrevious gpCurrent You are now ready to deploy this to the Zune for an audio-enabled experience. You may have found the process so simple that you might also decide to use this library in your 2D and 3D game projects on the PC and Xbox 360 as well. CHAPTER 27 We are sure you will notice how much more enjoyable your games are when you add audio using any of the alternatives provided in XNA. Chapter 27 review exercises To get the most from this chapter .