diff options
author | Daniel Weipert <code@drogueronin.de> | 2020-12-31 11:33:12 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2020-12-31 11:33:12 +0100 |
commit | fb64f15e22acfc1c03c7c5357dd66077454adbcf (patch) | |
tree | 96cdbb8f59bd65609aa76276dfba94f9cdad33d4 /UI/LevelSelect.gd |
Initial commit
Diffstat (limited to 'UI/LevelSelect.gd')
-rw-r--r-- | UI/LevelSelect.gd | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/UI/LevelSelect.gd b/UI/LevelSelect.gd new file mode 100644 index 0000000..c173a7b --- /dev/null +++ b/UI/LevelSelect.gd @@ -0,0 +1,23 @@ +extends Control + + +func _ready(): + var Cell = load("res://UI/LevelSelectCell.tscn") + + for idx in range(9): + var level = Global.get_level(idx) + var cell = Cell.instance() + cell.level_idx = idx + cell.set_rect_size(1024/3, 600/3) + var column = idx % 3 + var row = idx / 3 + cell.rect_position.x = cell.rect_size.x*column + cell.rect_position.y = cell.rect_size.y*row + cell.connect("gui_input", self, '_button_pressed', [idx]) + self.add_child(cell) + + +func _button_pressed(event, idx): + if event is InputEventMouseButton or event is InputEventKey: + if event.pressed: + Global.start_level(idx) |