Last active
October 12, 2015 12:07
-
-
Save alamboley/4024068 to your computer and use it in GitHub Desktop.
How to play sounds (Citrus Engine recipe)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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