extends Node2D
var my_nil = null
var my_bool = true
var my_int = 1
var my_real = 3.1314
var my_string = "string example"
var my_vector2 = Vector2(1,2)
# Called when the node enters the scene tree for the first time.
func _ready():
print(typeof(my_nil) == TYPE_NIL)
print(typeof(my_nil))
print(typeof(my_bool) == TYPE_BOOL)
print(typeof(my_int) == TYPE_INT)
print(typeof(my_real) == TYPE_REAL)
print(typeof(my_string) == TYPE_STRING)
print(typeof(my_vector2) == TYPE_VECTOR2)
print(typeof(my_real) == TYPE_RECT2)
print(typeof(my_real) == TYPE_VECTOR3)
print(typeof(my_real) == TYPE_TRANSFORM2D)
print(typeof(my_real) == TYPE_PLANE)
print(typeof(my_real) == TYPE_QUAT)
print(typeof(my_real) == TYPE_AABB)
print(typeof(my_real) == TYPE_BASIS)
print(typeof(my_real) == TYPE_TRANSFORM)
print(typeof(my_real) == TYPE_COLOR)
print(typeof(my_real) == TYPE_NODE_PATH)
print(typeof(my_real) == TYPE_RID)
print(typeof(my_real) == TYPE_OBJECT)
print(typeof(my_real) == TYPE_DICTIONARY)
print(typeof(my_real) == TYPE_ARRAY)
print(typeof(my_real) == TYPE_RAW_ARRAY)
print(typeof(my_real) == TYPE_INT_ARRAY)
print(typeof(my_real) == TYPE_REAL_ARRAY)
print(typeof(my_real) == TYPE_STRING_ARRAY)
print(typeof(my_real) == TYPE_VECTOR2_ARRAY)
print(typeof(my_real) == TYPE_VECTOR3_ARRAY)
print(typeof(my_real) == TYPE_COLOR_ARRAY)
typeof函数可以获得变量类型,变量类型是一个整数
--- Debugging process started ---
Godot Engine v3.5.3.stable.mono.official.6c814135b - https://godotengine.org
OpenGL ES 2.0 Renderer: NVIDIA GeForce RTX 3060/PCIe/SSE2
True
0
True
True
True
True
True
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
--- Debugging process stopped ---
变量类型定义
<constant name="TYPE_NIL" value="0" enum="Variant.Type">
Variable is [code]null[/code].
</constant>
<constant name="TYPE_BOOL" value="1" enum="Variant.Type">
Variable is of type [bool].
</constant>
<constant name="TYPE_INT" value="2" enum="Variant.Type">
Variable is of type [int].
</constant>
<constant name="TYPE_REAL" value="3" enum="Variant.Type">
Variable is of type [float] (real).
</constant>
<constant name="TYPE_STRING" value="4" enum="Variant.Type">
Variable is of type [String].
</constant>
<constant name="TYPE_VECTOR2" value="5" enum="Variant.Type">
Variable is of type [Vector2].
</constant>
<constant name="TYPE_RECT2" value="6" enum="Variant.Type">
Variable is of type [Rect2].
</constant>
<constant name="TYPE_VECTOR3" value="7" enum="Variant.Type">
Variable is of type [Vector3].
</constant>
<constant name="TYPE_TRANSFORM2D" value="8" enum="Variant.Type">
Variable is of type [Transform2D].
</constant>
<constant name="TYPE_PLANE" value="9" enum="Variant.Type">
Variable is of type [Plane].
</constant>
<constant name="TYPE_QUAT" value="10" enum="Variant.Type">
Variable is of type [Quat].
</constant>
<constant name="TYPE_AABB" value="11" enum="Variant.Type">
Variable is of type [AABB].
</constant>
<constant name="TYPE_BASIS" value="12" enum="Variant.Type">
Variable is of type [Basis].
</constant>
<constant name="TYPE_TRANSFORM" value="13" enum="Variant.Type">
Variable is of type [Transform].
</constant>
<constant name="TYPE_COLOR" value="14" enum="Variant.Type">
Variable is of type [Color].
</constant>
<constant name="TYPE_NODE_PATH" value="15" enum="Variant.Type">
Variable is of type [NodePath].
</constant>
<constant name="TYPE_RID" value="16" enum="Variant.Type">
Variable is of type [RID].
</constant>
<constant name="TYPE_OBJECT" value="17" enum="Variant.Type">
Variable is of type [Object].
</constant>
<constant name="TYPE_DICTIONARY" value="18" enum="Variant.Type">
Variable is of type [Dictionary].
</constant>
<constant name="TYPE_ARRAY" value="19" enum="Variant.Type">
Variable is of type [Array].
</constant>
<constant name="TYPE_RAW_ARRAY" value="20" enum="Variant.Type">
Variable is of type [PoolByteArray].
</constant>
<constant name="TYPE_INT_ARRAY" value="21" enum="Variant.Type">
Variable is of type [PoolIntArray].
</constant>
<constant name="TYPE_REAL_ARRAY" value="22" enum="Variant.Type">
Variable is of type [PoolRealArray].
</constant>
<constant name="TYPE_STRING_ARRAY" value="23" enum="Variant.Type">
Variable is of type [PoolStringArray].
</constant>
<constant name="TYPE_VECTOR2_ARRAY" value="24" enum="Variant.Type">
Variable is of type [PoolVector2Array].
</constant>
<constant name="TYPE_VECTOR3_ARRAY" value="25" enum="Variant.Type">
Variable is of type [PoolVector3Array].
</constant>
<constant name="TYPE_COLOR_ARRAY" value="26" enum="Variant.Type">
Variable is of type [PoolColorArray].
</constant>
<constant name="TYPE_MAX" value="27" enum="Variant.Type">
Represents the size of the [enum Variant.Type] enum.
</constant
标签:变量,TYPE,笔记,Variable,gdscript,typeof,type,print,my
From: https://www.cnblogs.com/nanfengshe/p/18111560