Binary Moon Posted August 10, 2014 Share Posted August 10, 2014 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 More sharing options...
toto88x Posted August 10, 2014 Share Posted August 10, 2014 Your last line should be something like this: game.add.tween(this.music[name]).to({volume:1}, 1000).start(); Link to comment Share on other sites More sharing options...
lewster32 Posted August 10, 2014 Share Posted August 10, 2014 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); Binary Moon 1 Link to comment Share on other sites More sharing options...
Binary Moon Posted August 10, 2014 Author Share Posted August 10, 2014 oh my - how did I forget the start()? Thanks for that! Link to comment Share on other sites More sharing options...
Recommended Posts