This is a fairly simple entry, but I wanted to have it here:
I made a character sheet for role playing games as a way to practice the GUI elements and to learn some parameters of the DnD sheet. I'm going to write below a few things to have into account when creating this kind of things in Godot, and also, for tips in some common mistakes that break projects and whose solutions are a nightmare to find, even when they are so simple.
To use a downloaded font (from PC) in TTF or any other format, create a new resource
https://forum.godotengine.org/t/how-do-you-bring-fonts-into-godot-3-0/29601/4
I made a character sheet for role playing games as a way to practice the GUI elements and to learn some parameters of the DnD sheet. I'm going to write below a few things to have into account when creating this kind of things in Godot, and also, for tips in some common mistakes that break projects and whose solutions are a nightmare to find, even when they are so simple.
To use a downloaded font (from PC) in TTF or any other format, create a new resource
https://forum.godotengine.org/t/how-do-you-bring-fonts-into-godot-3-0/29601/4
```
- Copy your TTF into your project folder
- You will see Godot import it as a
DynamicFontData
in the file browser - In the inspector click on the “new resource” icon and create a new
DynamicFont
. - In the
Font
category, click onFont data
and choose your TTF - Save the DynamicFont under the name you want (optional)
- You can now use this dynamic font where you want, change its size, spacing etc (without altering the original font).
```
And then, you can change the default font in project settings “custom font” property.
To create a toggle button, you need to add a 'check button', with this code below.
```
extends CheckButton
var show = false
func _on_VerTablaModificadores_toggled(_button_pressed):
$Tabla.visible = !show # Muestra o esconde la tabla segun la variable
show = !show # Actualiza la variable acorde a la visibilidad de la imagen en pantalla
```
Use the signals in that node to make it work,
```
extends CheckButton
var show = false
func _on_VerTablaModificadores_toggled(_button_pressed):
$Tabla.visible = !show # Muestra o esconde la tabla segun la variable
show = !show # Actualiza la variable acorde a la visibilidad de la imagen en pantalla
```
Use the signals in that node to make it work,
For the illustration to change according to your Option Button, you need this code in your illustration's texture rect:
```
extends TextureRect
# Size: x400 y500
# Pos: x540 y20
# Declare member variables here. Examples:
onready var especie = get_parent().get_node("ClaseEspecie/Especie")
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
var selectedID = especie.get_selected_id()
var ilustracion = "Ilustraciones/" + especie.get_item_text(selectedID) + ".png"
texture = load(ilustracion)
# Size: x400 y500
# Pos: x540 y20
# Declare member variables here. Examples:
onready var especie = get_parent().get_node("ClaseEspecie/Especie")
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
var selectedID = especie.get_selected_id()
var ilustracion = "Ilustraciones/" + especie.get_item_text(selectedID) + ".png"
texture = load(ilustracion)
```
This is the resulted sheet working:
Besides, you can find the code for this project freely available at:
With the release app to test if you have a 32 or 64 bits Windows, and a VPK for your PS Vita.
No comments:
Post a Comment