feat: choose outfit from library when creating a dragon
This commit is contained in:
parent
fd8609c0ab
commit
f07b28d2dc
22 changed files with 370 additions and 17 deletions
|
@ -6,8 +6,9 @@
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6eaxg"]
|
||||
size = Vector2(128, 128)
|
||||
|
||||
[node name="Dragon" type="Area2D"]
|
||||
[node name="Dragon" type="Area2D" node_paths=PackedStringArray("dragon")]
|
||||
script = ExtResource("1_jccds")
|
||||
dragon = NodePath("Dragon")
|
||||
|
||||
[node name="Dragon" parent="." instance=ExtResource("2_l1h0r")]
|
||||
position = Vector2(-64, -64)
|
||||
|
|
|
@ -2,7 +2,9 @@ extends Area2D
|
|||
class_name DragonEntity
|
||||
|
||||
|
||||
signal on_pick(position)
|
||||
@export var dragon: DragonSprite
|
||||
|
||||
signal on_pick(position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -13,5 +15,9 @@ func _input_event(viewport, event, shape_idx) -> void:
|
|||
if event is InputEventMouseButton \
|
||||
and event.button_index == MOUSE_BUTTON_LEFT \
|
||||
and event.is_pressed():
|
||||
on_pick.emit(position)
|
||||
on_pick.emit(position, dragon.hat.texture, dragon.shirt.texture, dragon.shoes.texture)
|
||||
queue_free()
|
||||
|
||||
|
||||
func dress(hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||
dragon.dress(hat, shirt, shoes)
|
||||
|
|
13
scenes/dragons/dragon_sprite.gd
Normal file
13
scenes/dragons/dragon_sprite.gd
Normal file
|
@ -0,0 +1,13 @@
|
|||
extends Node2D
|
||||
class_name DragonSprite
|
||||
|
||||
|
||||
@export var hat: Sprite2D
|
||||
@export var shirt: Sprite2D
|
||||
@export var shoes: Sprite2D
|
||||
|
||||
|
||||
func dress(hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||
self.hat.texture = hat
|
||||
self.shirt.texture = shirt
|
||||
self.shoes.texture = shoes
|
1
scenes/dragons/dragon_sprite.gd.uid
Normal file
1
scenes/dragons/dragon_sprite.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://bjiap06gs02j
|
|
@ -1,10 +1,36 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://baa8gpicw2yg0"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://baa8gpicw2yg0"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://fdqnc2qrrvn1" path="res://assets/sprites/icon.svg" id="1_ixu8j"]
|
||||
[ext_resource type="Script" uid="uid://bjiap06gs02j" path="res://scenes/dragons/dragon_sprite.gd" id="1_oaoux"]
|
||||
[ext_resource type="Texture2D" uid="uid://s1gx0l4qciqn" path="res://assets/sprites/hat.png" id="2_hdh4v"]
|
||||
[ext_resource type="Texture2D" uid="uid://dc2uk6tqtwl4n" path="res://assets/sprites/shirt.png" id="3_oaoux"]
|
||||
[ext_resource type="Texture2D" uid="uid://8srlwinjr3tt" path="res://assets/sprites/shoes.png" id="4_yf7bj"]
|
||||
|
||||
[node name="Dragon" type="Node2D"]
|
||||
[node name="Dragon" type="Node2D" node_paths=PackedStringArray("hat", "shirt", "shoes")]
|
||||
script = ExtResource("1_oaoux")
|
||||
hat = NodePath("Sprite/Hat")
|
||||
shirt = NodePath("Sprite/Shirt")
|
||||
shoes = NodePath("Sprite/Shoes")
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="."]
|
||||
position = Vector2(0, 1)
|
||||
texture = ExtResource("1_ixu8j")
|
||||
offset = Vector2(64, 64)
|
||||
|
||||
[node name="Hat" type="Sprite2D" parent="Sprite"]
|
||||
position = Vector2(39, 22)
|
||||
scale = Vector2(0.503906, 0.503906)
|
||||
texture = ExtResource("2_hdh4v")
|
||||
offset = Vector2(64, 64)
|
||||
|
||||
[node name="Shirt" type="Sprite2D" parent="Sprite"]
|
||||
position = Vector2(40, 56)
|
||||
scale = Vector2(0.477783, 0.288361)
|
||||
texture = ExtResource("3_oaoux")
|
||||
offset = Vector2(64, 64)
|
||||
|
||||
[node name="Shoes" type="Sprite2D" parent="Sprite"]
|
||||
position = Vector2(48, 39)
|
||||
scale = Vector2(0.353516, 0.353516)
|
||||
texture = ExtResource("4_yf7bj")
|
||||
offset = Vector2(64, 64)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue