music for hollywoo-flixel
This commit is contained in:
@@ -13,6 +13,7 @@ import hollywoo_flixel.FlxMovie;
|
|||||||
import flixel.util.FlxColor;
|
import flixel.util.FlxColor;
|
||||||
import flixel.text.FlxText;
|
import flixel.text.FlxText;
|
||||||
import flixel.system.FlxSound;
|
import flixel.system.FlxSound;
|
||||||
|
import flixel.util.FlxTimer;
|
||||||
|
|
||||||
@:build(kiss.Kiss.build())
|
@:build(kiss.Kiss.build())
|
||||||
class FlxDirector implements Director<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound> {}
|
class FlxDirector implements Director<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound, String> {}
|
||||||
|
|||||||
@@ -102,8 +102,27 @@
|
|||||||
(cc)
|
(cc)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
(method :Void playSound [:FlxSound sound :Float volumeMod :Continuation cc]
|
(method :Void playSound [:FlxSound sound :Float volumeMod :Bool waitForEnd :Continuation cc]
|
||||||
// TODO preserve its original volume
|
(let [originalVolume sound.volume
|
||||||
(set sound.volume volumeMod)
|
restoreOriginalVolume ->(set sound.volume originalVolume)]
|
||||||
(set sound.onComplete cc)
|
(*= sound.volume volumeMod)
|
||||||
(sound.play))
|
(set sound.onComplete
|
||||||
|
(if waitForEnd
|
||||||
|
->{(restoreOriginalVolume) (cc)}
|
||||||
|
restoreOriginalVolume)))
|
||||||
|
(sound.play)
|
||||||
|
(unless waitForEnd (cc)))
|
||||||
|
|
||||||
|
(prop &mut :FlxSound music)
|
||||||
|
(prop MUSIC_FADE_SEC 1)
|
||||||
|
(prop MUSIC_FADE_STEPS 10)
|
||||||
|
(method :Void playSong [:String song :Float volumeMod :Bool loop :Bool waitForEnd :Continuation cc]
|
||||||
|
(set music (FlxG.sound.play song 0 loop null true (if waitForEnd cc ->{})))
|
||||||
|
(.start (new FlxTimer)
|
||||||
|
(/ MUSIC_FADE_SEC MUSIC_FADE_STEPS)
|
||||||
|
->:Void _ (+= music.volume (/ volumeMod MUSIC_FADE_STEPS))
|
||||||
|
MUSIC_FADE_STEPS)
|
||||||
|
(set music.persist true)
|
||||||
|
(unless waitForEnd (cc)))
|
||||||
|
|
||||||
|
(method :Void stopSong [] (when music (music.stop)))
|
||||||
|
|||||||
@@ -29,4 +29,4 @@ enum FlxScreenPosition {
|
|||||||
/**
|
/**
|
||||||
* Model/controller of a Hollywoo-Flixel film, and main execution script
|
* Model/controller of a Hollywoo-Flixel film, and main execution script
|
||||||
*/
|
*/
|
||||||
class FlxMovie extends Movie<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound> {}
|
class FlxMovie extends Movie<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound, String> {}
|
||||||
|
|||||||
Reference in New Issue
Block a user