1
Answer

Calling a method that plays sound, mega troubles, please help!

Ray

Ray

13y
10.8k
1
Hey guys, I have a million questions but the main one I need ahelp with is that I have a method in a class that plays sound and I am trying to call that method in the mainscreen class. So I create a new instance of the class that contains the makenoise method but when I create a new instance and use the method it does not work.

Also if I leave the programme to run for a bit it tells me an out of memory error, I spent hours last night trying to solve these errors but I'm at a dead end, can anyone here make any suggestions please?

Here is some code that I am using I dont want to paste it all just the parts I have written that are supposed to function:

class Alien: Enemy
    {
        public SoundPlayer aliensound = new SoundPlayer(Properties.Resources.scream2);


  public override void MakeNoise()
        {
            aliensound.Play();
           
        }



    public partial class MainScreen : Form
    {
        Alien alien;
      
alien = new Alien(pictureBox1, GamePanel);


   alien.MakeNoise();//this code is used in the paintevent method after an alien is removed this sound should play for it dyiing



Many thanks to anyone who takes the time to help me out, I appreciate it!!!


Ray
Answers (1)