Camera and UI

This commit is contained in:
Felipe M 2021-02-04 19:53:22 +01:00
parent 7842e15c6c
commit edadd138b0
Signed by: fmartingr
GPG key ID: 716BC147715E716F
8 changed files with 65 additions and 5 deletions

View file

@ -0,0 +1,23 @@
extends Camera2D
var shake = 0
onready var timer = $Timer
func _ready():
Events.connect("add_screenshake", self, "_on_Events_add_screenshake")
func _process(delta):
offset_h = rand_range(-shake, shake)
offset_v = rand_range(-shake, shake)
func screenshake(amount, duration):
shake = amount
timer.wait_time = duration
timer.start()
func _on_Timer_timeout():
shake = 0
func _on_Events_add_screenshake(amount, duration):
screenshake(amount, duration)