Skip to content

Instantly share code, notes, and snippets.

@alamboley
Last active October 12, 2015 12:07
Show Gist options
  • Save alamboley/4024068 to your computer and use it in GitHub Desktop.
Save alamboley/4024068 to your computer and use it in GitHub Desktop.
How to play sounds (Citrus Engine recipe)
// In the Main class, register the sounds :
sound.addSound("Hurt", {sound:"sounds/hurt.mp3"});
sound.addSound("Collect", {sound:"sounds/collect.mp3"});
sound.addSound("Song", {sound:"sounds/song.mp3",timesToPlay:-1});
// In your GameState play them when needed :
private function handleHeroTakeDamage():void {
_ce.sound.playSound("Hurt");
}
private function handleJewelCollected(contact:b2Contact):void {
if (Box2DPhysicsObject.CollisionGetOther(self, contact) != _hero)
return;
_ce.sound.playSound("Collect");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment