Jump to content

Tween Sound Volume


Binary Moon
 Share

Recommended Posts

I am trying to tween a sound volume so I can have music fade in and out. I thought it would be super easy but for some reason it's not working :)

 

My code looks like this:

            this.music[name].loop = true;            this.music[name].volume = 0;            this.music[name].play();            game.add.tween(this.music[name]).to({volume:1});

Obviously I have already loaded and added the sound. If I remove the volume and tween code then it plays just fine.

 

Have I missed something or am I setting the property incorrectly?

Link to comment
Share on other sites

As above, or via the parameters of the tween:

            this.music[name].loop = true;            this.music[name].volume = 0;            this.music[name].play();            // params: properties to tween, length of tween in ms, ease (none for this) and automatically start tween            game.add.tween(this.music[name]).to({volume:1}, 1000, null, true);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...