Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site

Download Discussion > IntroProgXNAGameStudio [help]

Hi,

I've been working though your guild however I have got to the part 2 (images, sound & text) and started the Drum Pad tutorial but I've ran in to a Error I can't fix.

-----------------------------------------------------------------------------
Copy of my code
-----------------------------------------------------------------------------
// Game World
SoundEffect music;
SoundEffectInstance musicInstance = null;

if (oldpad1.Buttons.LeftShoulder == ButtonState.Released &&
pad1.Buttons.LeftShoulder == ButtonState.Pressed)
{
// Start the music playing
if (musicInstance == null)
{
// Need to create a SoundInstance to play the music.
musicInstance = music.Play();
}
else
{
// Already got a SoundInstance. Just play it.
musicInstance.Play();
}
}
The error occars on "musicInstance = music.Play();" Error reads :- Cannot implicitly convert type 'bool' to 'Microsoft.Xna.Framework.Audio.SoundEffectInstance' C:\Documents and Settings\Home\Desktop\MoodLight Game project\DrumPad\DrumPad\Game1.cs 140

Please help.
August 27, 2011 | Unregistered CommenterMattie B
Hi. Sorry you are having problems. The issue is because the sound API changed in the latest version of XNA. To play a sound you no longer need a SoundInstance. You can just go:

music.Play();
August 29, 2011 | Registered CommenterRob
Cheers for the reply, This as been the only problem I,ve had so far. Apart from that the guild is great, really easy to follow and I,ve learnt loads in a short time.

I chagned my code, its Build & deployed error free, HAPPY DAYS =)

Thankyou =)
August 29, 2011 | Unregistered CommenterMattie B