Open kingarthur0975 opened 2 days ago
I'd suggest never do like this. Bad for performance and quality. Always use separate AudioStreamPlayer for each sound. You could then create some sort of SFX manager class with function "play" that have similar functionality.
P.S. Animation is completely different story.
Describe the project you are working on
A 2D game that plays sound through code often
Describe the problem or limitation you are having in your project
It grinds my gears that AnimatedSprite and AnimationPlayer both get play() functions that let you add an argument for what animation to play, but to do basically the same thing on an AudioStreamPlayer, you must first set the stream manually before calling the play() function.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Simply adding an optional argument to AudioStreamPlayer's play() function: an AudioStream resource path to play.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Instead of writing this code: sound.stream = load("res://assets/sound/beep.ogg") sound.play()
Write this instead: sound.play("res://assets/sound/beep.ogg")
This wouldn't affect simply calling play() on an AudioStreamPlayer with a stream already defined in the inspector.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Obviously, it's a single line difference, but it would still be a useful quality-of-life change.
Is there a reason why this should be core and not an add-on in the asset library?
This makes function parity closer between different node types.