2021-10-03 14:43:19 +00:00
|
|
|
|
extends Object
|
|
|
|
|
|
|
|
|
|
|
2021-10-05 16:32:06 +00:00
|
|
|
|
# 移除node节点
|
2021-10-03 14:43:19 +00:00
|
|
|
|
static func removeNode(node: Node) -> void:
|
|
|
|
|
if (node == null):
|
|
|
|
|
return
|
|
|
|
|
var parent = node.get_parent()
|
|
|
|
|
if (parent == null):
|
2021-10-05 16:32:06 +00:00
|
|
|
|
node.queue_free()
|
2021-10-03 14:43:19 +00:00
|
|
|
|
return
|
|
|
|
|
parent.remove_child(node)
|
|
|
|
|
node.queue_free()
|
|
|
|
|
|
2021-10-05 16:32:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 实例化场景,并将场景添加到node中
|
|
|
|
|
static func addScene(node: Node, scene: PackedScene) -> Node:
|
|
|
|
|
var sceneNode = scene.instance()
|
|
|
|
|
node.add_child(sceneNode)
|
|
|
|
|
return sceneNode
|