use FlxSound for Song instead of String

This commit is contained in:
2023-07-03 07:11:14 -06:00
parent 156b08ec1f
commit 6aca7062d2
6 changed files with 20 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
# @install: lix --silent download "gh://github.com/kiss-lang/hollywoo#642996a85542eecab45e0c3b81e56e3a2ca6a8a8" into hollywoo/0.0.0/github/642996a85542eecab45e0c3b81e56e3a2ca6a8a8
# @run: haxelib run-dir hollywoo "${HAXE_LIBCACHE}/hollywoo/0.0.0/github/642996a85542eecab45e0c3b81e56e3a2ca6a8a8"
# @install: lix --silent download "gh://github.com/kiss-lang/hollywoo#c2a778da2d98498528715bab2628ccecab495595" into hollywoo/0.0.0/github/c2a778da2d98498528715bab2628ccecab495595
# @run: haxelib run-dir hollywoo "${HAXE_LIBCACHE}/hollywoo/0.0.0/github/c2a778da2d98498528715bab2628ccecab495595"
-lib kiss
-lib kiss-tools
-cp ${HAXE_LIBCACHE}/hollywoo/0.0.0/github/642996a85542eecab45e0c3b81e56e3a2ca6a8a8/src/
-cp ${HAXE_LIBCACHE}/hollywoo/0.0.0/github/c2a778da2d98498528715bab2628ccecab495595/src/
-D hollywoo=0.0.0

View File

@@ -1,12 +1,12 @@
# @install: lix --silent download "gh://github.com/kiss-lang/kiss#f41719122067499f60397353bd315c18740f5324" into kiss/0.0.1/github/f41719122067499f60397353bd315c18740f5324
# @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/kiss/0.0.1/github/f41719122067499f60397353bd315c18740f5324"
# @install: lix --silent download "gh://github.com/kiss-lang/kiss#9e916a482393c4aa45dfce0e63b4c53403d66238" into kiss/0.0.1/github/9e916a482393c4aa45dfce0e63b4c53403d66238
# @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/kiss/0.0.1/github/9e916a482393c4aa45dfce0e63b4c53403d66238"
-lib haxe-strings
-lib hscript
-lib tink_json
-lib tink_macro
-lib tink_syntaxhub
-lib uuid
-cp ${HAXE_LIBCACHE}/kiss/0.0.1/github/f41719122067499f60397353bd315c18740f5324/src
-cp ${HAXE_LIBCACHE}/kiss/0.0.1/github/9e916a482393c4aa45dfce0e63b4c53403d66238/src
-D kiss=0.0.1
-w -WUnusedPattern
--macro kiss.KissFrontend.use()

View File

@@ -38,7 +38,7 @@ import openfl.geom.Point;
import flixel.input.mouse.FlxMouseEventManager;
@:build(kiss.Kiss.build())
class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera, FlxLightSource> {
class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, FlxSound, FlxSprite, FlxSound, FlxCamera, FlxLightSource> {
public static function blackAlphaMaskFlxSprite(sprite:FlxSprite, mask:FlxSprite, output:FlxSprite):FlxSprite
{
sprite.drawFrame();

View File

@@ -1,7 +1,7 @@
(prop :FlxActionDigital continueAction)
(prop :FlxActionDigital fastForwardAction)
(prop actionManager (new FlxActionManager))
(prop &mut :Movie<FlxSprite,ActorFlxSprite,FlxSound,String,FlxSprite,FlxSound,FlxCamera,FlxLightSource> movie)
(prop &mut :Movie<FlxSprite,ActorFlxSprite,FlxSound,FlxSound,FlxSprite,FlxSound,FlxCamera,FlxLightSource> movie)
(defAlias &ident flxMovie (cast movie FlxMovie))
(loadFrom "hollywoo-flixel" "src/hollywoo_flixel/Aliases.kiss")
@@ -539,11 +539,8 @@
(method :Float getSoundLength [:FlxSound sound]
sound.length)
(method :Float getSongLength [:String song]
(let [sound (FlxG.sound.play song)
length sound.length]
(sound.stop)
length))
(method :Float getSongLength [:FlxSound song]
(/ song.length 1000))
(savedVar :Float voiceVolume 1.0)
@@ -574,13 +571,13 @@
(prop MUSIC_FADE_STEPS 10)
(savedVar :Float musicVolume 1.0)
(method :Void playSong [:String song :Float volumeMod :Bool loop :Bool waitForEnd :Continuation cc]
(method :Void playSong [:FlxSound song :Float volumeMod :Bool loop :Bool waitForEnd :Continuation cc]
(let [onFinish ->{
(currentSoundVolumes.remove music)
(set music null)
(when waitForEnd (cc))
}]
(set music (FlxG.sound.play song 0 loop null true onFinish))
(set music (FlxG.sound.play (Reflect.field song "_sound") 0 loop null true onFinish))
(dictSet currentSoundVolumes music [0 volumeMod])
(.start (new FlxTimer)
(/ MUSIC_FADE_SEC MUSIC_FADE_STEPS)
@@ -665,7 +662,7 @@
(layer.remove prop true))
(cc))
(prop :Array<FlxText> creditsText [])
(prop :kiss.List<FlxText> creditsText [])
(method _ctext [:String text :Int size]
(let [t (new FlxText 0 0 0 text size)]
(creditsText.push t)
@@ -680,8 +677,10 @@
(method :Void hideBlackScreen []
(FlxG.state.remove blackBG true))
(var IDEAL_SCROLL_SPEED 200)
// TODO currently the bg will cover whatever the final scene was - making after credits scenes impossible
(method :Void rollCredits [:Array<CreditsLine> credits cc]
(method :Void rollCredits [:Array<CreditsLine> credits cc &opt :Float timeLimit]
(localVar bg (new FlxSprite))
(bg.makeGraphic FlxG.width FlxG.height FlxColor.BLACK true)
(set bg.cameras [flxMovie.uiCamera])

View File

@@ -20,7 +20,7 @@ import flixel.tweens.FlxTween;
/**
* Model/controller of a Hollywoo-Flixel film, and main execution script
*/
class FlxMovie extends Movie<FlxSprite, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera, FlxLightSource> {
class FlxMovie extends Movie<FlxSprite, ActorFlxSprite, FlxSound, FlxSound, FlxSprite, FlxSound, FlxCamera, FlxLightSource> {
// Think of HollywooFlixelDSL.kiss as the corresponding Kiss file for this class!
public function new(director:FlxDirector, lightSourceJsonFile:String, positionsJson:String, delayLengthsJson:String, voiceLineMatchesJson:String, propScalesJson:String) {

View File

@@ -98,7 +98,9 @@
(newSound name s description)))
(method newFlxSong [name path]
(newSong name path))
(let [song (FlxG.sound.load path)]
(assert !(= 0 song.length) "song $name from $path has 0 length! avoid mp3s for this reason")
(newSong name song)))
(method newFlxVoiceTrack [name wavPath jsonPath]
(newVoiceTrack name (FlxG.sound.load wavPath) (openfl.utils.Assets.getText jsonPath)))