godot-start/script/demo02_base/base1.gd

60 lines
1.5 KiB
GDScript
Raw Normal View History

2021-09-12 10:07:51 +00:00
extends Node2D
2021-10-20 03:52:25 +00:00
2022-01-03 06:38:29 +00:00
# 导出一个数字
2021-09-12 10:07:51 +00:00
export var a = 1
2022-01-03 06:38:29 +00:00
# 导出一个节点路径
2021-09-12 10:07:51 +00:00
export var b:NodePath
2022-01-03 06:38:29 +00:00
# 导出一个节点路径,不同的写法
2021-09-12 10:07:51 +00:00
export(NodePath) var c
2022-01-03 06:38:29 +00:00
# 导出一个文件路径
2021-09-12 10:07:51 +00:00
export(String, FILE) var e
2022-01-03 06:38:29 +00:00
# 导出一个文件路径以txt结尾
2021-09-12 10:07:51 +00:00
export(String, FILE, "*.txt") var d
2022-01-03 06:38:29 +00:00
# 导出一个资源文件路径
2021-09-12 10:07:51 +00:00
export(Resource) var f
2022-01-03 06:38:29 +00:00
# 导出一个颜色
2021-09-12 10:07:51 +00:00
export(Color, RGB) var g
2021-10-20 03:52:25 +00:00
2022-01-02 12:00:16 +00:00
func _init():
print("init")
2021-09-12 10:07:51 +00:00
# Called when the node enters the scene tree for the first time.
func _ready():
2022-01-02 12:00:16 +00:00
print("ready")
2021-09-12 10:07:51 +00:00
print("new一个对象--------------------------------")
var myClass = MyClass.new()
print(myClass.to_string())
2022-01-03 08:59:00 +00:00
print("数据类型信息--------------------------------")
2021-09-12 10:07:51 +00:00
myClass.typeInfo()
2022-01-02 10:47:19 +00:00
print("基础语法if else--------------------------------")
myClass.if_function(1, 2)
print("基础语法switch--------------------------------")
myClass.switch_function()
print("基础语法while for--------------------------------")
myClass.loop_function()
print("数组遍历--------------------------------")
myClass.arrayIterator()
print("字典遍历--------------------------------")
myClass.dictionaryIterator()
2021-09-12 10:07:51 +00:00
print("访问静态变量--------------------------------")
var answer = MyClass.ANSWER
print("访问const变量类似于static变量" + answer as String)
print("调用静态方法--------------------------------")
print("调用静态方法:" + MyClass.getAnswer() as String)
print("内部类测试--------------------------------")
myClass.innerClassTest()