Initial Android commit
This commit is contained in:
commit
1e2b80c13d
8521 changed files with 231475 additions and 0 deletions
88
scripts/TweenBGM.gd
Normal file
88
scripts/TweenBGM.gd
Normal file
|
@ -0,0 +1,88 @@
|
|||
extends Tween
|
||||
|
||||
const fadeMusicTime = 0.8;
|
||||
const lowVolume = - 80;
|
||||
const defaultVolume:float = 0.0;
|
||||
var bgmStream:AudioStreamPlayer;
|
||||
|
||||
var darkChild:Sprite;
|
||||
|
||||
func _ready():
|
||||
bgmStream = self.get_child(0);
|
||||
bgmStream.bus = "BGM";
|
||||
|
||||
loopEnable = false;
|
||||
|
||||
func PlayBGM(bgmPath):
|
||||
PrepareLoopVersion(bgmPath);
|
||||
|
||||
bgmStream.volume_db = lowVolume;
|
||||
bgmStream.stream = load(bgmPath);
|
||||
|
||||
var _temp = self.interpolate_property(bgmStream, "volume_db", lowVolume, defaultVolume, fadeMusicTime, Tween.TRANS_EXPO, 0)
|
||||
if bgmPath == "res://resources/audio/bgm/25.ogg":
|
||||
bgmStream.play(1.5);
|
||||
else :
|
||||
bgmStream.play(0.0);
|
||||
_temp = self.start();
|
||||
|
||||
func StopBGM():
|
||||
|
||||
var _temp = self.interpolate_property(bgmStream, "volume_db", defaultVolume, lowVolume, fadeMusicTime, Tween.TRANS_LINEAR, 0)
|
||||
_temp = self.start();
|
||||
loopEnable = false
|
||||
yield (self, "tween_all_completed");
|
||||
if bgmStream.stream != null:
|
||||
bgmStream.stream.resource_path = ""
|
||||
bgmStream.stream = null;
|
||||
|
||||
func ChangeBGM(bgmPath2):
|
||||
if bgmStream.stream != null and bgmStream.stream.resource_path == bgmPath2:
|
||||
return ;
|
||||
|
||||
var bgmPath3 = bgmPath2.trim_suffix(".ogg") + "_loop.ogg"
|
||||
|
||||
if bgmStream.stream.resource_path == bgmPath2 or bgmStream.stream.resource_path == bgmPath3:
|
||||
return ;
|
||||
|
||||
StopBGM();
|
||||
yield (self, "tween_all_completed")
|
||||
PlayBGM(bgmPath2);
|
||||
|
||||
func SetNextTriptych(bgmPath):
|
||||
loopEnable = true;
|
||||
bgmStream.stream.set_loop_mode(0);
|
||||
loopVersionPath = bgmPath;
|
||||
|
||||
var dict = {
|
||||
"res://resources/audio/bgm/14.ogg":"res://resources/audio/bgm/14_loop.ogg",
|
||||
"res://resources/audio/bgm/17.ogg":"res://resources/audio/bgm/17_loop.ogg",
|
||||
"res://resources/audio/bgm/18.ogg":"res://resources/audio/bgm/18_loop.ogg",
|
||||
"res://resources/audio/bgm/19.ogg":"res://resources/audio/bgm/19_loop.ogg",
|
||||
"res://resources/audio/bgm/20.ogg":"res://resources/audio/bgm/20_loop.ogg",
|
||||
"res://resources/audio/bgm/21.ogg":"res://resources/audio/bgm/21_loop.ogg",
|
||||
"res://resources/audio/bgm/22.ogg":"res://resources/audio/bgm/22_loop.ogg",
|
||||
"res://resources/audio/bgm/23.ogg":"res://resources/audio/bgm/23_loop.ogg",
|
||||
"res://resources/audio/bgm/26.ogg":"res://resources/audio/bgm/26_loop.ogg",
|
||||
}
|
||||
|
||||
var loopEnable;
|
||||
var loopVersionPath;
|
||||
|
||||
func PrepareLoopVersion(bgmPath):
|
||||
if dict.has(bgmPath):
|
||||
loopVersionPath = dict[bgmPath];
|
||||
loopEnable = true;
|
||||
else :
|
||||
loopVersionPath = "";
|
||||
loopEnable = false;
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_BGMStreamPlayer_finished():
|
||||
if loopEnable:
|
||||
bgmStream.stream = load(loopVersionPath);
|
||||
bgmStream.play(0.0);
|
||||
loopEnable = false;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue