Jump to content
Search Community

Pixi Plugin : Using Pixi Sound

mrbuchmas test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

I'm wanting to use GSAP with Pixi Sound to fade audio in and out. The docs say that the plugin works with the main Pixi code base, does that include Pixi Sound? If not, is there another way to still use GSAP with Pixi Sound?

Link to comment
Share on other sites

GSAP can animate literally any property of any object that JavaScript can touch. So you should certainly be able to use GSAP to animate anything in PIXI. I'm not very familiar with Pixi, sorry, but just find the property that you need to animate for the volume/sound, and create a tween that targets that. Give it a try and if you get stuck, pop back here with a minimal demo that illustrates the problem and we'll do our best to help with any GSAP-specific questions. 

Link to comment
Share on other sites

  • Solution

Hi,

 

Based on a quick look here:

https://pixijs.io/sound/examples/

https://pixijs.io/sound/docs/Sound.html#volume

 

You could do something like this:

const sound = PIXI.sound.Sound.from('resources/boing.mp3');
sound.volume = 0;
sound.play();
gsap.to(sound, { volume: 1 });

I'm not sure if the PIXI Plugin would work with sounds, since it was created to be used with PIXI display objects, but you could try and see how it goes, if it doesn't work you can try the code I proposed above.

 

Hopefully this helps.

Happy Tweening!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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