PBS-KIDS / Platypus

2D tile based game framework in HTML5
128 stars 30 forks source link

Audio on Scene Change #12

Closed pleduc closed 10 years ago

pleduc commented 10 years ago

I was wondering if there was an event I could have an audio component listen for so as soon as the scene that contains the audio component loads, the audio fires. Like for when the title screen loads having a "Welcome to the game" audio. Or audio with the level's objective as soon as that level loads. Or will I have to trigger this manually with my own component?

probityrules commented 10 years ago

The scene triggers "scene-loaded" and "scene-live" events on each layer. If your audio component is attached to an entity on the layer, you just need to add "scene-live" (or "scene-loaded") to the entity-container childEvents list so the entity (and audio component) hear it.

pleduc commented 10 years ago

Thank you! This worked perfectly. I have another question about audio, but I think it would be smarter to open a new thread.

probityrules commented 10 years ago

Awesome, glad it worked! Closing this thread out.