12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- extends ColorRect
- class_name TimeLeftBar
- var max_time_left = 10.0
- var time_left = max_time_left
- var active = false
- var time_left_bar_bg = ColorN("white")
- var time_left_bar_fg = ColorN("gray").darkened(0.3)
- onready var TOP_PANEL = find_parent("top_panel")
- var fg_rect
- var ping_label
- # Called when the node enters the scene tree for the first time.
- func _ready():
- color = time_left_bar_bg
-
- fg_rect = ColorRect.new()
- fg_rect.color = time_left_bar_fg
- fg_rect.rect_size.y = rect_size.y
- call_deferred("add_child",fg_rect)
-
- ping_label = FontedLabel.new()
- ping_label.rect_size = rect_size
- ping_label.font_size = rect_size.y * 0.4
- ping_label.align = Label.ALIGN_CENTER
- ping_label.valign = Label.ALIGN_CENTER
- ping_label.text = "ping label"
- ping_label.modulate = ColorN("black")
- call_deferred("add_child",ping_label)
- func _process(delta):
- if active:
- time_left -=delta
- ping_label.text = str(floor(time_left*10)/10.0)
- fg_rect.rect_size.x = (max_time_left - time_left)/max_time_left*rect_size.x
- func activate():
- active = true
- max_time_left = TOP_PANEL.planet.jam_till_finish + 1
- time_left = max_time_left
- func deactivate():
- active = false
- # Called every frame. 'delta' is the elapsed time since the previous frame.
- #func _process(delta):
- # pass
|