首页 > 其他分享 >gdscript学习笔记2-变量及变量类型

gdscript学习笔记2-变量及变量类型

时间:2024-04-02 21:34:38浏览次数:13  
标签:变量 TYPE 笔记 Variable gdscript typeof type print my

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

相关文章

  • 莫比乌斯反演学习笔记
    莫比乌斯反演学习笔记前言之前学了一遍,只学了朴素的莫比乌斯反演,现在第二次面对不知道能否有所长进。性质莫比乌斯反演是数论中的重要内容。对于一些函数\(f(n)\),如果难以直接求出它的值,但容易求得其倍数和或约数和\(g(n)\),那么可以通过莫比乌斯函数反演简化运算,从而求得\(......
  • 数论分块学习笔记
    数论分块学习笔记性质数论分块用于快速计算含有除法向下取整的和式,即形如\(\sum_{i=1}^nf(i)g(\lfloor\frac{n}{i}\rfloor)\)的式子。当预处理出\(f\)的前缀和时,数论分块可以在\(O(\sqrt{n})\)的时间复杂度下计算上述和式的值。求解引理\(1\):\(\foralla,b,c\in\math......
  • python变量和简单的数据类型[第 2 章(上)]
    2.1运行解释文件扩展名:结尾的.py用于指出文件内容是Python代码Python解释器:读取整个文件,确定其中每一行的含义并执行例如,当解释器看到print,就会将括号中的内容打印到屏幕上。语法高亮:用不同的颜色,区分出程序代码中的不同部分 2.2变量修改我们在上一章中写的代......
  • Python笔记----列表(List)【附代码】
    1.列表介绍   列表既是Python中最基本的数据结构又是最常用的数据类型   创造列表很简单,只要把数据用中括号括起来,数据之间用逗号隔开就可以了。2.列表的创建   列表的数据项不需要具有相同的类型,不同数据类型都可以装,可以存储的信息非常丰富3.列表......
  • docker笔记
    常用命令临时启动镜像dockerrun-it--rm--namexxximage-name启动容器dockerrun-it-d--name-v/path:/path-p80:80-eMYSQL_USER="test"image-name进入容器dockerexec-itdocker-namebashnvidiadocker容器内使用显卡参考:https://cloud.tencent.com/devel......
  • Kotlin基础-变量
    1.变量vara:Int=2//声明一个变量vara=3//明确知道类型的情况下可以不标明类型vara:Int//不知道类型的情况下要声明类型vara:String?=null//声明一个String?类型,值可以为String也可以为nulllateinitvara:String//必须为不可null类型,后面要......
  • Vue学习笔记72--element ui
    VueUI组件库:https://element.eleme.cn移动端常用UI组件库Vant:https://youzan.github.io/vantCubeUI:https://didi.github.io/cube-uiMintUI:https://mint-ui.github.ioNUTUI。。。。。。PC端常用UI组件库ElementUI:https://element.eleme.cnIViewUI:https://www.ivi......
  • ARM架构银河麒麟使用笔记-安装KVM
    ARM架构银河麒麟使用笔记-安装KVMarm银河麒麟KVM现在的平台是,主机用的是ubuntu,里面用qemu开启了arm架构的银河麒麟系统,系统可以访问百度。要做的事情是:在这个银河麒麟系统中,再安装qemu,再用qemu创建一个x86_64位的CentOS7.9.2009的系统,这个系统使用qemu的虚拟网桥方式与银河麒麟......
  • UOS使用笔记
    备份WPS序列号文件管理器点放大镜输入/opt/kingsoft/.auth/回车,然后把license2.dat文件复制出来备份,重装后再复制回去。添加柯尼卡美能达打印机柯尼卡美能达官网、统信兼容应用清单里提供的驱动都不全,少数有提供驱动的,也无法实现多面打印、彩色打印等基础功能。对此需要在......
  • python selenium 速查笔记
    1.安装与配置pipinstallselenium基本使用selenium都是为了动态加载网页内容用于爬虫,所以一般也会用到phantomjsmac下如果要配置phantomjs环境的话echo$PATHln-s<phantomjs地址><PATH中任一路径>至于chromeDriver,配置方法类似,下载地址:https://sites.google.com/a/chro......