Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building your First Mobile Game using XNA 4.0

You're reading from   Building your First Mobile Game using XNA 4.0 A fast-paced, hands-on guide to building a 3D game for the Windows Phone 7 platform using XNA 4.0

Arrow left icon
Product type Paperback
Published in Jan 2013
Publisher Packt
ISBN-13 9781849687744
Length 158 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Thomas Goussaert Thomas Goussaert
Author Profile Icon Thomas Goussaert
Thomas Goussaert
Brecht Kets Brecht Kets
Author Profile Icon Brecht Kets
Brecht Kets
Arrow right icon
View More author details
Toc

Playing 3D sound


When playing sounds, for instance an explosion, it's nice that the sound of the explosion actually appears to be coming from the explosion. This can be done using 3D sound. The basic setup is very similar as using a SoundEffectInstance, because it has support for 3D sound. We just need some extra classes: an AudioEmitter and an AudioListener. The emitter represents the object that will cause the sound, for instance in case of an explosion, the bomb. The emitter will have the same position as the object that creates the sound. The listener represents the object that receives the sound. In case of a game, it would be the player, and thus have the same position. Both the emitter and the listener have a property called Forward; with the emitter, it defines the direction in which the sound should travel; with the listener, if defines the direction in which the listener is oriented. They both have properties for the position, the up vector and the velocity. The emitter also has...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image