Audio Playback

From TRCCompSci - AQA Computer Science
Revision as of 10:22, 26 May 2024 by Admin (talk | contribs) (Created page with "=Sound Effects= You will need to declare a SoundEffect: SoundEffect effect; In LoadContent you can then load in your sound effect: effect = Content.Load<SoundEffect>("MyS...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Sound Effects

You will need to declare a SoundEffect:

SoundEffect effect;

In LoadContent you can then load in your sound effect:

effect = Content.Load<SoundEffect>("MySoundEffect");

You can then use the play method to play it when you want:

effect.Play();

Or you can set these and then play the sound effect:

float volume = 1.0f;
float pitch = 0.0f;
float pan = 0.0f;
effect.Play(volume, pitch, pan);

Background Music