mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 15:01:53 +08:00
f52f7cda8e
refactor(子弹基类): 重构销毁逻辑防止重复调用 fix(敌人): 调整小鸡boss的出现波次和激光音效 style(场景文件): 整理动画资源顺序
27 lines
681 B
GDScript
27 lines
681 B
GDScript
extends Node2D
|
|
class_name EffectController
|
|
|
|
@export var oneShot: bool = true
|
|
|
|
@onready var particles: GPUParticles2D = $"%particles"
|
|
|
|
func _ready():
|
|
particles.emitting = false
|
|
particles.one_shot = oneShot
|
|
func shot():
|
|
var cloned = particles.duplicate() as GPUParticles2D
|
|
cloned.emitting = true
|
|
add_child(cloned)
|
|
if oneShot:
|
|
await cloned.finished
|
|
cloned.queue_free()
|
|
|
|
static func create(scene: PackedScene, spawnPosition: Vector2, parent: Node2D = null) -> EffectController:
|
|
var cloned = scene.instantiate() as EffectController
|
|
cloned.global_position = spawnPosition
|
|
if parent:
|
|
parent.add_child(cloned)
|
|
else:
|
|
WorldManager.rootNode.add_child(cloned)
|
|
return cloned
|