Initial commit: dynamic music & FX players
Continuous music players (DynamicSoundPlayer, 2D, 3D) with intensity-blended layers, playlist queue, Loop, fade in/out, pause/resume. One-shot SFX players (DynamicSoundFXPlayer, 2D, 3D) for overlapping triggers. All variants share RefCounted core classes via duck-typed property access. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
@tool
|
||||
@icon("res://addons/gd-dynamic-sound/icon.svg")
|
||||
class_name DynamicSoundFXPlayer2D
|
||||
## 2D positional variant of [DynamicSoundFXPlayer].
|
||||
##
|
||||
## Each [method play_fx] call triggers a fresh play of the assigned
|
||||
## [DynamicSound], layered with any plays still in flight, distance-attenuated
|
||||
## from a 2D position relative to the listener.
|
||||
extends AudioStreamPlayer2D
|
||||
|
||||
## The [DynamicSound] to trigger. Each [method play_fx] call plays a fresh instance.
|
||||
@export var Sound : DynamicSound;
|
||||
|
||||
## Volume mix between intensity layers. Only blended when all three layers are set.
|
||||
@export_range(0, 1) var Intensity : float = 0;
|
||||
|
||||
var _core : DynamicSoundFXPlayerCore;
|
||||
|
||||
func _enter_tree() -> void:
|
||||
if Engine.is_editor_hint() and stream == null:
|
||||
stream = AudioStreamPolyphonic.new();
|
||||
|
||||
func _ready() -> void:
|
||||
_core = DynamicSoundFXPlayerCore.new(self);
|
||||
_core.ready();
|
||||
|
||||
## Trigger a one-shot of [member Sound]. Layers with any in-flight triggers.
|
||||
func play_fx() -> void:
|
||||
if _core: _core.play_fx();
|
||||
Reference in New Issue
Block a user