Use static typing in all demos (#1063)

This leads to code that is easier to understand and runs
faster thanks to GDScript's typed instructions.

The untyped declaration warning is now enabled on all projects
where type hints were added. All projects currently run without
any untyped declration warnings.

Dodge the Creeps and Squash the Creeps demos intentionally don't
use type hints to match the documentation, where type hints haven't
been adopted yet (given its beginner focus).
This commit is contained in:
Hugo Locurcio
2024-06-01 12:12:18 +02:00
committed by GitHub
parent 8e9c180278
commit bac1e69164
498 changed files with 5218 additions and 4776 deletions

View File

@@ -1,12 +1,12 @@
@tool
extends Node2D
var heart = preload("res://addons/custom_node/heart.png")
func _draw():
draw_texture(heart, -heart.get_size() / 2)
const HEART_TEXTURE := preload("res://addons/custom_node/heart.png")
func _get_item_rect():
# override
return Rect2(-heart.get_size() / 2, heart.get_size())
func _draw() -> void:
draw_texture(HEART_TEXTURE, -HEART_TEXTURE.get_size() / 2)
func _get_item_rect() -> Rect2:
return Rect2(-HEART_TEXTURE.get_size() / 2, HEART_TEXTURE.get_size())

View File

@@ -1,11 +1,12 @@
@tool
extends EditorPlugin
func _enter_tree():
# When this plugin node enters tree, add the custom type
func _enter_tree() -> void:
# When this plugin node enters tree, add the custom type.
add_custom_type("Heart", "Node2D", preload("res://addons/custom_node/heart.gd"), preload("res://addons/custom_node/heart_icon.png"))
func _exit_tree():
# When the plugin node exits the tree, remove the custom type
func _exit_tree() -> void:
# When the plugin node exits the tree, remove the custom type.
remove_custom_type("Heart")