Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @tool
- extends TextureRect
- #EXPORTS
- @export_category("Button Type")
- enum type {new_game,continue_game,settings,quit} #EVERY BUTTON TYPE
- @export var button_type : type #WE SET WHAT TYPE OF BUTTON WE WANT IT TO BE
- @export_category("Children")
- @export var button : Button #BUTTON ITSELF
- @export var border : TextureRect #BUTTON BORDER
- @export_category("Costumization")
- @export var button_text : String = "default" : set = set_button_text #TEXT ON THE BUTTON
- @export var button_text_size : int = 1 : set = set_text_size #TEXT SIZE OF THE BUTTON
- @export var border_color : Color = Color.WHITE : set = set_color #COLOR OF THE BUTTONS'S BORDER
- #CHANGE THE TEXT OF THE BUTTON
- func set_button_text(new_text : String):
- button_text = new_text
- button.text = new_text
- #ADJUST THE TEXT SIZE OF THE BUTTON
- func set_text_size(new_size : int):
- button_text_size = new_size
- button.add_theme_font_size_override("font_size", new_size)
- #CHANGE COLOR OF THE BORDER
- func set_color(new_color : Color):
- border_color = new_color
- border.self_modulate = new_color
- #CHECK FOR THE BUTTON TYPE, AND MOVE TO THE DESIRED SCENE
- func _on_button_pressed():
- match button_type:
- type.new_game:
- #START NEW GAME HERE!
- pass
- type.continue_game:
- #WE RESUME OUR GAME!
- pass
- type.settings:
- #I TOO HATE WORKING ON GAME SETTINGS
- pass
- type.quit:
- #WE STOP PLAYING
- get_tree().quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement