des bruits de pas
tralala
This commit is contained in:
@@ -6,7 +6,7 @@ var songs = [
|
||||
"res://assest/music/balade du grand nord.ogg",
|
||||
]
|
||||
|
||||
var current_song = -1
|
||||
var current_song = 0
|
||||
|
||||
func _ready() -> void:
|
||||
$AnimationPlayer.play("play")
|
||||
@@ -14,15 +14,19 @@ func _ready() -> void:
|
||||
func _process(delta: float) -> void:
|
||||
if $AudioStreamPlayer2D.get_playback_position() != 0:
|
||||
GameState.float_thomas_music_position = $AudioStreamPlayer2D.get_playback_position()
|
||||
var stream : AudioStream = $AudioStreamPlayer2D.stream
|
||||
if stream:
|
||||
var l = stream.get_length()
|
||||
if is_zero_approx(l - GameState.float_thomas_music_position):
|
||||
play_next_song()
|
||||
|
||||
func _on_load_from_game_state() -> void:
|
||||
$AudioStreamPlayer2D.play(GameState.float_thomas_music_position)
|
||||
|
||||
func _on_audio_stream_player_2d_finished() -> void:
|
||||
play_next_song()
|
||||
if GameState.float_thomas_music_position > 1:
|
||||
$AudioStreamPlayer2D.seek(GameState.float_thomas_music_position)
|
||||
print("resume from pause ", songs[current_song], "at ", GameState.float_thomas_music_position)
|
||||
$AudioStreamPlayer2D.stream_paused = false
|
||||
|
||||
func play_next_song():
|
||||
$AudioStreamPlayer2D.stop()
|
||||
current_song += 1
|
||||
if current_song == songs.size():
|
||||
current_song = 0
|
||||
@@ -30,4 +34,7 @@ func play_next_song():
|
||||
$AudioStreamPlayer2D.stream= load(songs[current_song]);
|
||||
GameState.float_thomas_music_position = 0
|
||||
$AudioStreamPlayer2D.play(GameState.float_thomas_music_position)
|
||||
$AnimationPlayer.play("play")
|
||||
|
||||
|
||||
func _on_outside_unload_from_screen() -> void:
|
||||
$AudioStreamPlayer2D.stream_paused = true
|
||||
|
||||
Reference in New Issue
Block a user