June 2018
Beginner to intermediate
298 pages
7h 38m
English
Add the following script to the UI to update the UI elements:
extends CanvasLayervar bar_red = preload("res://assets/bar_red.png")var bar_green = preload("res://assets/bar_green.png")var bar_yellow = preload("res://assets/bar_yellow.png")func update_shots(value): $Margin/Container/Shots.text = 'Shots: %s' % valuefunc update_powerbar(value): $Margin/Container/PowerBar.texture_progress = bar_green if value > 70: $Margin/Container/PowerBar.texture_progress = bar_red elif value > 40: $Margin/Container/PowerBar.texture_progress = bar_yellow $Margin/Container/PowerBar.value = value
The two functions provide a way to update the UI elements when they need to display a new value. As you did in the Space Rocks game, changing the progress bar's texture ...
Read now
Unlock full access