fix null error when movie ends

This commit is contained in:
2023-09-30 22:04:23 -06:00
parent 864e8f4507
commit c612fe7e79
2 changed files with 15 additions and 4 deletions

View File

@@ -466,12 +466,14 @@
(set lightSprite null)))
(method :Void cleanup []
(when music (stopSong))
(hideTitleCard)
(hideBlackScreen)
(hideDialog)
(hideLighting)
(when flxMovie.sceneKey
(when (and flxMovie.sceneKey (< 0 (Lambda.count flxMovie.scenes)))
(let [scene (dictGet flxMovie.scenes flxMovie.sceneKey)]
(hideSet scene.set scene.camera ->:Void {})
(doFor prop scene.props
@@ -804,6 +806,8 @@
(method loadSong [path]
(let [song (FlxG.sound.load path)]
(assert !(= 0 song.length) "song from $path has 0 length! avoid mp3s for this reason")
(set song.persist true)
(set song.autoDestroy false)
song))
(method :Float getSongLength [:FlxSound song]
@@ -815,7 +819,10 @@
(prop :Map<FlxSound,Function> restoreOriginalVolumes (new Map))
(method loadVoiceTrack [wavPath]
(FlxG.sound.load wavPath))
(let [vt (FlxG.sound.load wavPath)]
(set vt.persist true)
(set vt.autoDestroy false)
vt))
(method :Void playVoiceTrack [:FlxSound track :Float volumeMod :Float start :Float end :Continuation cc]
(let [originalVolume track.volume

View File

@@ -4,7 +4,7 @@
(loadFrom "hollywoo" "src/hollywoo/Movie.kiss")
(loadFrom "hollywoo-flixel" "src/hollywoo_flixel/Aliases.kiss")
(method :Dynamic callPrivate [:Dynamic obj :String method &rest :Array<Dynamic> args]
(function :Dynamic callPrivate [:Dynamic obj :String method &rest :Array<Dynamic> args]
(Reflect.callMethod obj (Reflect.field obj method) args))
(method newFlxTextProp [:String key :String text :Int size :FlxColor color &opt :String font]
@@ -569,7 +569,11 @@
(function destroyAndClear [:kiss.FuzzyMap<Dynamic> m]
(doFor =>key thing m
(thing.destroy))
(typeCase [thing]
([:FlxSound sound]
(callPrivate FlxG.sound "destroySound" sound))
(otherwise
(thing.destroy))))
(m.clear))
(defMacro addSkips [flxMovieClass]