working ish buttons
This commit is contained in:
parent
abb39db50c
commit
1bcd7bcea9
@ -2,8 +2,8 @@
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/level.gd" id="1_0nmok"]
|
||||
[ext_resource type="PackedScene" uid="uid://b8s2seg2lf7wo" path="res://Scenes/Tilemaps/tileset_1.tscn" id="1_4n82n"]
|
||||
[ext_resource type="PackedScene" uid="uid://dgtscjxcqoxls" path="res://Scenes/Props/candle_1.tscn" id="2_5hdq4"]
|
||||
[ext_resource type="PackedScene" uid="uid://cf7al5uln33rn" path="res://Scenes/Props/candle_2.tscn" id="2_o33c4"]
|
||||
[ext_resource type="PackedScene" uid="uid://cl7w6ndvons1a" path="res://Scenes/Props/candle_1.tscn" id="2_5hdq4"]
|
||||
[ext_resource type="PackedScene" uid="uid://by2xmwcng01uy" path="res://Scenes/Props/candle_2.tscn" id="2_o33c4"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5lnjonlf4i1b" path="res://Scenes/enemy.tscn" id="4_g0oey"]
|
||||
[ext_resource type="PackedScene" uid="uid://0onqgygm832d" path="res://Scenes/Player/player.tscn" id="5_ik47y"]
|
||||
|
||||
|
4
Scenes/Player/UI/MenuZone.gd
Normal file
4
Scenes/Player/UI/MenuZone.gd
Normal file
@ -0,0 +1,4 @@
|
||||
extends Control
|
||||
|
||||
func _on_mouse_exited():
|
||||
if not Rect2(Vector2(), size).has_point(get_local_mouse_position()):
|
22
Scenes/Player/UI/bat_button.tscn
Normal file
22
Scenes/Player/UI/bat_button.tscn
Normal file
@ -0,0 +1,22 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dl0d1m1gfcd4o"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://f7n8gd1wlv4v" path="res://Scenes/Player/UI/spawnable_button.tscn" id="1_tvnet"]
|
||||
[ext_resource type="PackedScene" uid="uid://brnx3xyyd0e71" path="res://Scenes/Spawnables/bat_spawnable.tscn" id="2_borla"]
|
||||
[ext_resource type="Texture2D" uid="uid://ddvr5ltbo8ome" path="res://Assets/Bat/noBKG_BatFlight_strip.png" id="3_5io10"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_if561"]
|
||||
resource_local_to_scene = true
|
||||
atlas = ExtResource("3_5io10")
|
||||
region = Rect2(64, 0, 64, 64)
|
||||
|
||||
[node name="BatButton" instance=ExtResource("1_tvnet")]
|
||||
spawnableScene = ExtResource("2_borla")
|
||||
|
||||
[node name="AnimatedTextureRect" parent="." index="0"]
|
||||
texture = SubResource("AtlasTexture_if561")
|
||||
|
||||
[node name="Label" parent="." index="2"]
|
||||
text = "Bat"
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
|
13
Scenes/Player/UI/player_ui.gd
Normal file
13
Scenes/Player/UI/player_ui.gd
Normal file
@ -0,0 +1,13 @@
|
||||
extends Control
|
||||
|
||||
@onready var menuZone : Control = $MenuZone
|
||||
@export var buttonGroup : ButtonGroup
|
||||
|
||||
signal button_changed(currentButton : Button)
|
||||
|
||||
func _ready():
|
||||
for i in buttonGroup.get_buttons():
|
||||
i.pressed.connect(on_button_changed)
|
||||
|
||||
func on_button_changed():
|
||||
button_changed.emit(buttonGroup.get_pressed_button())
|
@ -1,18 +1,43 @@
|
||||
[gd_scene format=3 uid="uid://dmvukn3rl6gbx"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dmvukn3rl6gbx"]
|
||||
|
||||
[node name="PlayerUI" type="CanvasLayer"]
|
||||
[ext_resource type="Script" path="res://Scenes/Player/UI/player_ui.gd" id="1_4nwdk"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl0d1m1gfcd4o" path="res://Scenes/Player/UI/bat_button.tscn" id="1_tnnk6"]
|
||||
[ext_resource type="ButtonGroup" uid="uid://gjbbywsr8n8b" path="res://Scenes/Player/UI/spawnables_button_group.tres" id="3_7a133"]
|
||||
|
||||
[node name="UIRoot" type="Control" parent="."]
|
||||
[node name="PlayerUI" type="Control"]
|
||||
layout_mode = 3
|
||||
anchor_top = 0.874
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 9.0
|
||||
offset_top = 9.0
|
||||
offset_right = -9.0
|
||||
offset_bottom = -13.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_4nwdk")
|
||||
buttonGroup = ExtResource("3_7a133")
|
||||
|
||||
[node name="MenuZone" type="Control" parent="."]
|
||||
layout_mode = 1
|
||||
anchor_top = 0.859
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = 0.139984
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="UIRoot" type="Control" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 16.0
|
||||
offset_top = -60.0
|
||||
offset_right = -16.0
|
||||
offset_bottom = -12.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="ControlPanel" type="HBoxContainer" parent="UIRoot"]
|
||||
layout_mode = 1
|
||||
@ -21,14 +46,33 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
theme_override_constants/separation = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="StatPanel" type="Control" parent="UIRoot/ControlPanel"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="ButtonPanel" type="HBoxContainer" parent="UIRoot/ControlPanel"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
mouse_filter = 2
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="SpawnableButton" parent="UIRoot/ControlPanel/ButtonPanel" instance=ExtResource("1_tnnk6")]
|
||||
layout_mode = 2
|
||||
button_group = ExtResource("3_7a133")
|
||||
|
||||
[node name="SpawnableButton2" parent="UIRoot/ControlPanel/ButtonPanel" instance=ExtResource("1_tnnk6")]
|
||||
layout_mode = 2
|
||||
button_group = ExtResource("3_7a133")
|
||||
|
||||
[node name="SpawnableButton3" parent="UIRoot/ControlPanel/ButtonPanel" instance=ExtResource("1_tnnk6")]
|
||||
layout_mode = 2
|
||||
button_group = ExtResource("3_7a133")
|
||||
|
||||
[node name="SpawnableButton4" parent="UIRoot/ControlPanel/ButtonPanel" instance=ExtResource("1_tnnk6")]
|
||||
layout_mode = 2
|
||||
button_group = ExtResource("3_7a133")
|
||||
|
13
Scenes/Player/UI/spawnable_button.gd
Normal file
13
Scenes/Player/UI/spawnable_button.gd
Normal file
@ -0,0 +1,13 @@
|
||||
class_name SpawnableButton
|
||||
extends Button
|
||||
|
||||
@export var spawnableScene : PackedScene = null
|
||||
|
||||
@onready var animationPlayer : AnimationPlayer = $AnimationPlayer
|
||||
|
||||
func _on_mouse_entered():
|
||||
animationPlayer.play("AnimateTextureRect")
|
||||
|
||||
|
||||
func _on_mouse_exited():
|
||||
animationPlayer.stop()
|
@ -1,21 +1,98 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://f7n8gd1wlv4v"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://f7n8gd1wlv4v"]
|
||||
|
||||
[sub_resource type="AnimatedTexture" id="AnimatedTexture_iksd1"]
|
||||
[ext_resource type="Theme" uid="uid://dr1h7to56a2pv" path="res://Themes/base_theme.tres" id="1_ep8kc"]
|
||||
[ext_resource type="Texture2D" uid="uid://ddvr5ltbo8ome" path="res://Assets/Bat/noBKG_BatFlight_strip.png" id="1_w23sr"]
|
||||
[ext_resource type="Script" path="res://Scenes/Player/UI/spawnable_button.gd" id="2_d0sgh"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_10isv"]
|
||||
resource_local_to_scene = true
|
||||
atlas = ExtResource("1_w23sr")
|
||||
region = Rect2(64, 0, 64, 64)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_r6yl2"]
|
||||
resource_name = "AnimateTextureRect"
|
||||
length = 0.666675
|
||||
loop_mode = 1
|
||||
step = 0.0833333
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedTextureRect:texture:region")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0833333, 0.166667, 0.25, 0.333333, 0.416667, 0.5, 0.583333),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [Rect2(0, 0, 64, 64), Rect2(64, 0, 64, 64), Rect2(128, 0, 64, 64), Rect2(192, 0, 64, 64), Rect2(256, 0, 64, 64), Rect2(320, 0, 64, 64), Rect2(384, 0, 64, 64), Rect2(448, 0, 64, 64)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_tak1b"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AnimatedTextureRect:texture:region")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Rect2(64, 0, 64, 64)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_0o4ue"]
|
||||
_data = {
|
||||
"AnimateTextureRect": SubResource("Animation_r6yl2"),
|
||||
"RESET": SubResource("Animation_tak1b")
|
||||
}
|
||||
|
||||
[node name="SpawnableButton" type="Button"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_right = -854.0
|
||||
offset_bottom = -499.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
mouse_default_cursor_shape = 2
|
||||
theme = ExtResource("1_ep8kc")
|
||||
toggle_mode = true
|
||||
script = ExtResource("2_d0sgh")
|
||||
|
||||
[node name="Animation" type="TextureRect" parent="."]
|
||||
[node name="AnimatedTextureRect" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchors_preset = -1
|
||||
anchor_left = -1.78302
|
||||
anchor_top = -0.414634
|
||||
anchor_right = 2.78302
|
||||
anchor_bottom = 1.14634
|
||||
offset_left = 210.0
|
||||
offset_right = -210.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("AtlasTexture_10isv")
|
||||
stretch_mode = 5
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_0o4ue")
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -18.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("AnimatedTexture_iksd1")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Animation"]
|
||||
grow_vertical = 0
|
||||
theme = ExtResource("1_ep8kc")
|
||||
text = "Template"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
5
Scenes/Player/UI/spawnables_button_group.tres
Normal file
5
Scenes/Player/UI/spawnables_button_group.tres
Normal file
@ -0,0 +1,5 @@
|
||||
[gd_resource type="ButtonGroup" format=3 uid="uid://gjbbywsr8n8b"]
|
||||
|
||||
[resource]
|
||||
resource_local_to_scene = false
|
||||
allow_unpress = true
|
@ -1,15 +1,12 @@
|
||||
extends Node2D
|
||||
|
||||
@export var batTemplatePath : PackedScene
|
||||
var currentSpawnableScene : PackedScene = null
|
||||
@onready var menuZone : Control = $Camera2D/CanvasLayer/PlayerUI.menuZone
|
||||
@onready var enemy : CharacterBody2D = $"../Enemy"
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
handle_menu_inputs()
|
||||
|
||||
if Input.is_action_just_pressed("place_spawnable"):
|
||||
spawn_bat()
|
||||
handle_spawn()
|
||||
|
||||
func handle_menu_inputs():
|
||||
if Input.is_action_just_pressed("fullscreen_toggle"):
|
||||
@ -18,8 +15,30 @@ func handle_menu_inputs():
|
||||
else:
|
||||
get_window().mode = Window.MODE_EXCLUSIVE_FULLSCREEN
|
||||
|
||||
func spawn_bat():
|
||||
var bat = batTemplatePath.instantiate()
|
||||
bat.global_position = get_global_mouse_position()
|
||||
$"..".add_child(bat)
|
||||
$"../Enemy".add_foe(bat)
|
||||
func handle_spawn():
|
||||
if Input.is_action_just_pressed("place_spawnable"):
|
||||
spawn_current()
|
||||
|
||||
func spawn_current():
|
||||
if is_in_menu() || currentSpawnableScene == null:
|
||||
return
|
||||
var spawnable = currentSpawnableScene.instantiate()
|
||||
spawnable.global_position = get_global_mouse_position()
|
||||
$"..".add_child(spawnable)
|
||||
if enemy != null:
|
||||
enemy.add_foe(spawnable)
|
||||
|
||||
|
||||
func is_in_menu():
|
||||
return menuZone.get_rect().has_point(get_local_mouse_position())
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_player_ui_button_changed(currentButton):
|
||||
if currentButton == null:
|
||||
currentSpawnableScene = null
|
||||
return
|
||||
|
||||
currentSpawnableScene = currentButton.spawnableScene
|
||||
|
||||
|
@ -1,12 +1,16 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://0onqgygm832d"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://0onqgygm832d"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/Player/player.gd" id="1_63swt"]
|
||||
[ext_resource type="PackedScene" uid="uid://brnx3xyyd0e71" path="res://Scenes/Spawnables/bat_spawnable.tscn" id="2_fd41r"]
|
||||
[ext_resource type="PackedScene" uid="uid://dmvukn3rl6gbx" path="res://Scenes/Player/UI/player_ui.tscn" id="3_nbue7"]
|
||||
|
||||
[node name="Player" type="Node2D"]
|
||||
script = ExtResource("1_63swt")
|
||||
batTemplatePath = ExtResource("2_fd41r")
|
||||
|
||||
[node name="PlayerUI" parent="." instance=ExtResource("3_nbue7")]
|
||||
metadata/_edit_use_anchors_ = true
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
anchor_mode = 0
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="Camera2D"]
|
||||
|
||||
[node name="PlayerUI" parent="Camera2D/CanvasLayer" instance=ExtResource("3_nbue7")]
|
||||
|
||||
[connection signal="button_changed" from="Camera2D/CanvasLayer/PlayerUI" to="." method="_on_player_ui_button_changed"]
|
||||
|
@ -12,4 +12,3 @@ func _process(delta):
|
||||
|
||||
func win_screen():
|
||||
get_tree().change_scene_to_file("res://Scenes/start_menu.tscn")
|
||||
|
||||
|
@ -9,6 +9,7 @@ bg_color = Color(0.403922, 0.0117647, 0.0627451, 0.188235)
|
||||
bg_color = Color(0.803922, 0.152941, 0.188235, 1)
|
||||
|
||||
[resource]
|
||||
default_font = ExtResource("1_i16b1")
|
||||
Label/fonts/font = ExtResource("1_i16b1")
|
||||
ProgressBar/styles/background = SubResource("StyleBoxFlat_hf10d")
|
||||
ProgressBar/styles/fill = SubResource("StyleBoxFlat_jy7e3")
|
||||
|
Loading…
x
Reference in New Issue
Block a user