*GODOT3 튜토리얼 : Scriptable Objects
https://www.youtube.com/watch?v=wuxal3C0800
ClassStats 클래스를 생성 (extends Resource)
Resource 창에서 우클릭 new Resource - ClassStats 생성
#ClassStats.gd
extends Resource
class_name ClassStats
export(String) var type = "Knight"
export(int) var health = 100
export(int) var strength = 100
export(int) var intelligence = 100
export(Image) var profile = null
#ClassDsplay.gd
extends Panel
onready var profile_image = get_node("MarginContainer/HBoxContainer/CenterContainer/TextureRect")
onready var class_label = get_node("MarginContainer/HBoxContainer/VBoxContainer/Class/Data")
onready var health_label = get_node("MarginContainer/HBoxContainer/VBoxContainer/Health/Data")
onready var strength_label = get_node("MarginContainer/HBoxContainer/VBoxContainer/Strength/Data")
onready var intelligence_label = get_node("MarginContainer/HBoxContainer/VBoxContainer/Intelligence/Data")
func _ready():
var class_data = load("res://Thief.tres")
update_class_display(class_data)
func update_class_display(class_data):
profile_image.texture = class_data.profile
class_label.text = class_data.type
health_label.text = str(class_data.health)
strength_label.text = str(class_data.strength)
intelligence_label.text = str(class_data.intelligence)
func _on_KnightButton_pressed():
var class_data = load("res://Knight.tres")
update_class_display(class_data)
func _on_WizardButton_pressed():
var class_data = load("res://Wizard.tres")
update_class_display(class_data)
func _on_ThiefButton_pressed():
var class_data = load("res://Thief.tres")
update_class_display(class_data)
'개발 > 고도 엔진.Godot engine' 카테고리의 다른 글
GODOT3 튜토리얼 : Make an Action RPG in Godot 3.2 (0) | 2021.05.21 |
---|---|
Godot 3.2 Autotile bitmask (0) | 2020.10.01 |
GODOT 3 튜터리얼 메모 - 2D Platformer Game (0) | 2020.08.30 |
modules/mono/glue/gd_glue.cpp:250 - Cannot find dotnet CLI executable. Fallback to MSBuild from Visual Studio. (0) | 2020.08.16 |
고도 메모 GODOT (0) | 2020.06.02 |