I am currently working on a game menu with 3 options: New game
, Load Game
, and Options
. I have also attached a piece of code to New Game
to make it print something for now. I have also added a custom font, and I made some code which is supposed to change the default font to the font I loaded into my res://
folder. Here is the code:
extends Button
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
#-----Font section------#
func _fonts():
var font = DynamicFont.new()
font.font_data = load("res://Mandala Vintage.ttf")
$Button.set("custom_fonts/font", font)
#------Font section over-----#
# Bind "New game" to key press: enter
var current_font = null
var unused_font = load("res://Mandala Vintage.ttf")
func _process(_delta):
if Input.is_action_pressed("ui_accept"):
var dynamicFont = get("custom_fonts/font")
current_font = dynamicFont.font_data
dynamicFont.font_data = unused_font
unused_font = current_font
# Done
# Called when the node enters the scene tree for the first time.
# Create a new button
func _ready():
var button = Button.new()
button.text = "New Game"
button.connect("pressed", self, "_button_pressed")
add_child(button)
# Add a function to the button
func _button_pressed():
print("Create a new window here")