Kaynağa Gözat

Add missing binding to AudioStream class

This allows for the extension of AudioStream where you can call
`instance_plackback` on child AudioStream instances within gdscript,
much like the implementation of some child classes in C++.

See `AudioStreamRandomPitch` for an example of how this can be used.
Eoin O'Neill 3 yıl önce
ebeveyn
işleme
ded9dc1e82
2 değiştirilmiş dosya ile 7 ekleme ve 0 silme
  1. 6 0
      doc/classes/AudioStream.xml
  2. 1 0
      servers/audio/audio_stream.cpp

+ 6 - 0
doc/classes/AudioStream.xml

@@ -39,6 +39,12 @@
 				Returns the length of the audio stream in seconds.
 			</description>
 		</method>
+		<method name="instance_playback">
+			<return type="AudioStreamPlayback" />
+			<description>
+				Returns an AudioStreamPlayback. Useful for when you want to extend `_instance_playback` but call `instance_playback` from an internally held AudioStream subresource. An example of this can be found in the source files for `AudioStreamRandomPitch::instance_playback`.
+			</description>
+		</method>
 		<method name="is_monophonic" qualifiers="const">
 			<return type="bool" />
 			<description>

+ 1 - 0
servers/audio/audio_stream.cpp

@@ -200,6 +200,7 @@ bool AudioStream::is_monophonic() const {
 void AudioStream::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("get_length"), &AudioStream::get_length);
 	ClassDB::bind_method(D_METHOD("is_monophonic"), &AudioStream::is_monophonic);
+	ClassDB::bind_method(D_METHOD("instance_playback"), &AudioStream::instance_playback);
 	GDVIRTUAL_BIND(_instance_playback);
 	GDVIRTUAL_BIND(_get_stream_name);
 	GDVIRTUAL_BIND(_get_length);