mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-05 10:09:47 +03:00
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:
@@ -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())
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user