Camera and UI
This commit is contained in:
parent
7842e15c6c
commit
edadd138b0
8 changed files with 65 additions and 5 deletions
23
metroidvania/Scenes/World/Camera.gd
Normal file
23
metroidvania/Scenes/World/Camera.gd
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue