Hello Guest

Author Topic: Sound and Sound Attenuation  (Read 326 times)

0 Members and 1 Guest are viewing this topic.

Power_Michael

  • Member
  • Posts: 1
    • View Profile
Sound and Sound Attenuation
« on: May 23, 2017, 08:44:14 PM »
I am trying to implement sound that fades with distance in my game, so I have created a player who moves about a scene, and a boombox object that stays in one fixed location. I then defined the following in the boombox : entity class:
Code: [Select]
        Sound sound1 = new Sound("Sounds/salt.ogg", false);


        //Constructor
        public Boombox(float x, float y) : base(x, y) {
            var image = Image.CreateRectangle(32, Color.Orange);
            image.CenterOrigin();
            AddGraphic(image);

           // asf
            sound1.CenterSound(X, Y);
            sound1.RelativeToListener = false;
            sound1.Volume = 1;
            sound1.MinimumDistance = 0.5f;
            sound1.Attenuation = 2;
            sound1.Play();

and then in my player I have this line of code inside of my Update() method:

Code: [Select]
Sound.CenterListener(X, Y);
When I run the game, the song plays, but it doesn't fade when the player is farther away.
---Do note that it (sound1) is a full length song, and it is an .ogg.

So how would I go about making this work? Or does this feature not work properly? Please help :D

https://www.pifsc.noaa.gov/hawaiian_monk_seal/img/myth8_med.jpg // a seal to be ironic

-Michael
« Last Edit: May 23, 2017, 08:46:16 PM by Power_Michael »