good weapon switcher
This commit is contained in:
parent
608c4a73c7
commit
caefc9ad94
11 changed files with 237 additions and 14 deletions
29
player/weapon_ui.gd
Normal file
29
player/weapon_ui.gd
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
class_name WeaponUI
|
||||
extends Control
|
||||
|
||||
const DIFF = 25
|
||||
const TIME = 0.2
|
||||
|
||||
var active_weapon := 0:
|
||||
set(v):
|
||||
if v == active_weapon: return
|
||||
|
||||
get_child(active_weapon).create_tween() \
|
||||
.set_trans(Tween.TRANS_QUAD) \
|
||||
.set_ease(Tween.EASE_OUT) \
|
||||
.tween_property(get_child(active_weapon), "position", initial_positions[active_weapon], TIME)
|
||||
|
||||
active_weapon = v
|
||||
|
||||
get_child(v).create_tween() \
|
||||
.set_trans(Tween.TRANS_QUAD) \
|
||||
.set_ease(Tween.EASE_OUT) \
|
||||
.tween_property(get_child(v), "position", initial_positions[v] + Vector2.UP * DIFF, TIME)
|
||||
var initial_positions: PackedVector2Array
|
||||
|
||||
func _ready() -> void:
|
||||
for child in get_children():
|
||||
initial_positions.push_back(child.position)
|
||||
|
||||
get_child(active_weapon).position += Vector2.UP * DIFF
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue