changed the way the fall sprite works

This commit is contained in:
pennyrigate 2023-06-20 08:20:35 -04:00
parent 67e9a93b2b
commit 929b63c454
10 changed files with 179 additions and 42 deletions

View file

@ -3,6 +3,7 @@ extends Area2D
export var speed = 16.0
onready var sprite = $Sprite
onready var activation_timer = $ActivationTimer
var lifetime = 0.0
@ -15,10 +16,16 @@ func _physics_process(delta):
sprite.position.x = sin(lifetime * 4.0) * 4.0
position.y -= speed * delta
func _on_Bubble_body_entered(body):
func pop():
sprite.frame_coords.y = 1
speed = 0.0
get_tree().create_timer(0.5, false).connect("timeout", self, "queue_free")
func _on_Bubble_body_entered(body):
if body.is_in_group("player"):
body.oxygen_timer.start()
Audio.play_sound(Audio.a_bubble,Audio.ac_die)
pop()
elif activation_timer.time_left == 0:
pop()

View file

@ -17,5 +17,11 @@ vframes = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="ActivationTimer" type="Timer" parent="."]
autostart = true
__meta__ = {
"_editor_description_": "timer until the bubble can be broken by objects other than the player"
}
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
[connection signal="body_entered" from="." to="." method="_on_Bubble_body_entered"]

View file

@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://objects/environment/bubble/bubble.tscn" type="PackedScene" id=1]
[ext_resource path="res://scripts/random_spawner.gd" type="Script" id=2]
[node name="BubbleSpawner" type="Node2D"]
position = Vector2( 16, 158 )
script = ExtResource( 2 )
scene = ExtResource( 1 )
extents = Rect2( 0, 0, 16, 8 )
delay = 3.0