HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.92k stars 427 forks source link

Add onVolumeChange to SoundFrontEnd #3148

Closed ACrazyTown closed 1 month ago

ACrazyTown commented 1 month ago

info: #3147

This acts the same as volumeHandler except it's just a FlxSignal. Not sure what to do with volumeHandler, should it be marked as deprecated?

Geokureli commented 1 month ago

can you walk me through what the existing field volumeHandler is, and how it was intended to be used? This is the first time I'm coming across it

ACrazyTown commented 1 month ago

can you walk me through what the existing field volumeHandler is, and how it was intended to be used? This is the first time I'm coming across it

volumeHandler is just a function callback that gets called whenever the global volume is changed. It's meant to be replaced by your own function like this:

FlxG.sound.volumeHandler = function(volume:Float) {
   // do something when the volume is changed
};

Not sure what other use cases there might be but I personally used it to get openfl.media.Video to play nicely with Flixel's sound system

Geokureli commented 1 month ago

Should we deprecate it?

ACrazyTown commented 1 month ago

Should we deprecate it?

I don't see why not

Geokureli commented 1 month ago

It's still giving deprecation warnings:

SoundFrontEnd.hx:343: characters 7-20 : Warning : volumeHandler is deprecated, use onVolumeChange, instead SoundFrontEnd.hx:345: characters 4-17 : Warning : volumeHandler is deprecated, use onVolumeChange, instead SoundFrontEnd.hx:466: characters 7-20 : Warning : volumeHandler is deprecated, use onVolumeChange, instead SoundFrontEnd.hx:468: characters 4-17 : Warning : volumeHandler is deprecated, use onVolumeChange, instead

I'll have to mess with this locally, when i have time later, unless you can figure it out, first

ACrazyTown commented 1 month ago

I don't seem to be getting any deprecation warnings. I tried building the TurnBasedRPG demo on hl & html5, debug and release. Uncommenting the fix you added makes them show up, otherwise I get nothing

Geokureli commented 1 month ago

I was looking at the 4.2.5 job, which doesn't have the ability to suppress warnings in methods. it does seem to work fine on 4.3.3