Initial Android commit
This commit is contained in:
commit
1e2b80c13d
8521 changed files with 231475 additions and 0 deletions
74
scripts/CustomControls/Lightning.gd
Normal file
74
scripts/CustomControls/Lightning.gd
Normal file
|
@ -0,0 +1,74 @@
|
|||
extends Node2D
|
||||
|
||||
var state;
|
||||
var playerReference:AudioStreamPlayer;
|
||||
|
||||
var scenePath;
|
||||
var imagesLoaded;
|
||||
|
||||
func _ready():
|
||||
pass;
|
||||
|
||||
func Init(number:int, audioPlayer:AudioStreamPlayer):
|
||||
state = number;
|
||||
playerReference = audioPlayer;
|
||||
|
||||
imagesLoaded = false;
|
||||
|
||||
var _temp = SceneLoader.connect("on_scene_loaded", self, "ImagesLoaded");
|
||||
scenePath = str("res://resources/customControls/Lightning/Lightning", number, ".tscn");
|
||||
if not ResourceLoader.exists(scenePath):
|
||||
OS.alert("МОЛНИИ НЕТ!!!");
|
||||
SceneLoader.load_scene(scenePath)
|
||||
|
||||
func SetPosition(pos:Vector2, _scale:Vector2):
|
||||
yield (get_tree().create_timer(0.1), "timeout");
|
||||
position = pos;
|
||||
scale = _scale;
|
||||
|
||||
|
||||
func ImagesLoaded(obj):
|
||||
if obj.path != scenePath:
|
||||
return ;
|
||||
|
||||
add_child(obj.instance);
|
||||
obj.instance.connect("animation_finished", self, "_on_Animation_animation_finished");
|
||||
imagesLoaded = true;
|
||||
SceneLoader.disconnect("on_scene_loaded", self, "ImagesLoaded");
|
||||
|
||||
func StartAnimation():
|
||||
if not has_node("Animation"):
|
||||
return ;
|
||||
|
||||
var sprite:AnimatedSprite = $Animation;
|
||||
|
||||
if sprite.is_playing():
|
||||
return ;
|
||||
|
||||
sprite.visible = true;
|
||||
sprite.frame = 0;
|
||||
|
||||
sprite.play("default");
|
||||
|
||||
func _process(_delta):
|
||||
if not imagesLoaded:
|
||||
return ;
|
||||
|
||||
if playerReference == null:
|
||||
return
|
||||
|
||||
var time = playerReference.get_playback_position();
|
||||
|
||||
match playerReference.stream.resource_path:
|
||||
"res://resources/audio/sfx/Rain Loop.ogg":
|
||||
if time >= 2.4 and time <= 2.5:
|
||||
StartAnimation();
|
||||
"res://resources/audio/sfx/Mayak_night.ogg":
|
||||
if time >= 3.1 and time <= 3.2:
|
||||
StartAnimation();
|
||||
_:
|
||||
pass;
|
||||
|
||||
func _on_Animation_animation_finished():
|
||||
if has_node("Animation"):
|
||||
$Animation.visible = false;
|
Loading…
Add table
Add a link
Reference in a new issue