forked from team-sg/hero-mark-2
create bubble environmental particle
This commit is contained in:
parent
6028efa329
commit
71134758af
3 changed files with 42 additions and 0 deletions
22
objects/environment/bubble/bubble.gd
Normal file
22
objects/environment/bubble/bubble.gd
Normal file
|
@ -0,0 +1,22 @@
|
|||
extends Area2D
|
||||
|
||||
export var speed = 16.0
|
||||
|
||||
onready var sprite = $Sprite
|
||||
|
||||
var lifetime = 0.0
|
||||
|
||||
func _ready():
|
||||
sprite.frame_coords.x = randi() % sprite.hframes
|
||||
|
||||
func _physics_process(delta):
|
||||
lifetime += delta
|
||||
if speed > 0.0:
|
||||
sprite.position.x = sin(lifetime * 4.0) * 4.0
|
||||
position.y -= speed * delta
|
||||
|
||||
func _on_area_entered(area):
|
||||
if area.is_in_group("player") or area.is_in_group("arrow"):
|
||||
sprite.frame_coords.y = 1
|
||||
speed = 0.0
|
||||
get_tree().create_timer(0.5, false).connect("timeout", self, "queue_free")
|
Loading…
Add table
Add a link
Reference in a new issue