forked from team-sg/hero-mark-2
changed the way the fall sprite works
This commit is contained in:
parent
67e9a93b2b
commit
929b63c454
10 changed files with 179 additions and 42 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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"]
|
||||
|
|
11
objects/environment/bubble/bubble_spawner.tscn
Normal file
11
objects/environment/bubble/bubble_spawner.tscn
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue