1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-07-03 16:52:13 +08:00

fix(特效): 修复格挡特效的旋转和纹理锁定问题

调整格挡特效的旋转角度计算,使其正确朝向子弹方向
添加lockTexture属性防止特效纹理旋转
优化粒子效果和动画播放顺序
This commit is contained in:
2026-03-22 14:12:02 +08:00
parent aeb8729a1b
commit 128e9d51ff
3 changed files with 75 additions and 34 deletions
+66 -30
View File
@@ -1,8 +1,9 @@
[gd_scene load_steps=14 format=3 uid="uid://bwbhxnuhmkwww"] [gd_scene load_steps=25 format=3 uid="uid://bwbhxnuhmkwww"]
[ext_resource type="PackedScene" uid="uid://bcvuuy2m0pke0" path="res://components/Abstracts/EffectBase.tscn" id="1_vc7s4"] [ext_resource type="PackedScene" uid="uid://bcvuuy2m0pke0" path="res://components/Abstracts/EffectBase.tscn" id="1_vc7s4"]
[ext_resource type="Texture2D" uid="uid://bdvyebq7sepqf" path="res://resources/effects/parry/ParrySparkAccurate0.png" id="2_kic6n"] [ext_resource type="Texture2D" uid="uid://bdvyebq7sepqf" path="res://resources/effects/parry/ParrySparkAccurate0.png" id="2_kic6n"]
[ext_resource type="AudioStream" uid="uid://caxopva6lrlm3" path="res://resources/sounds/effect/swordhit.ogg" id="2_l0pl0"] [ext_resource type="AudioStream" uid="uid://caxopva6lrlm3" path="res://resources/sounds/effect/swordhit.ogg" id="2_l0pl0"]
[ext_resource type="Texture2D" uid="uid://7jhhyoinptns" path="res://resources/items/soul.svg" id="3_buxs5"]
[ext_resource type="Texture2D" uid="uid://bsq0s07h5u6fp" path="res://resources/effects/parry/ParrySparkAccurate1.png" id="3_l0pl0"] [ext_resource type="Texture2D" uid="uid://bsq0s07h5u6fp" path="res://resources/effects/parry/ParrySparkAccurate1.png" id="3_l0pl0"]
[ext_resource type="Texture2D" uid="uid://myolsnuud6jk" path="res://resources/effects/parry/ParrySparkAccurate2.png" id="4_buxs5"] [ext_resource type="Texture2D" uid="uid://myolsnuud6jk" path="res://resources/effects/parry/ParrySparkAccurate2.png" id="4_buxs5"]
[ext_resource type="Texture2D" uid="uid://cu72mlaga1ge4" path="res://resources/effects/parry/ParrySparkAccurate3.png" id="5_471em"] [ext_resource type="Texture2D" uid="uid://cu72mlaga1ge4" path="res://resources/effects/parry/ParrySparkAccurate3.png" id="5_471em"]
@@ -11,33 +12,60 @@
[ext_resource type="Texture2D" uid="uid://cvommbyvqfp1p" path="res://resources/effects/parry/ParrySparkAccurate6.png" id="8_molrd"] [ext_resource type="Texture2D" uid="uid://cvommbyvqfp1p" path="res://resources/effects/parry/ParrySparkAccurate6.png" id="8_molrd"]
[ext_resource type="Texture2D" uid="uid://rv10oe25rb6c" path="res://resources/effects/parry/ParrySparkAccurate.png" id="9_76bi2"] [ext_resource type="Texture2D" uid="uid://rv10oe25rb6c" path="res://resources/effects/parry/ParrySparkAccurate.png" id="9_76bi2"]
[sub_resource type="Animation" id="Animation_kic6n"] [sub_resource type="Curve" id="Curve_471em"]
resource_name = "spawn" _data = [Vector2(0.5, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
step = 0.1 point_count = 2
tracks/0/type = "method"
tracks/0/imported = false [sub_resource type="CurveTexture" id="CurveTexture_tu1jt"]
tracks/0/enabled = true curve = SubResource("Curve_471em")
tracks/0/path = NodePath("%stage/../texture")
tracks/0/interp = 1 [sub_resource type="Curve" id="Curve_f5km5"]
tracks/0/loop_wrap = true _data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
tracks/0/keys = { point_count = 2
"times": PackedFloat32Array(0, 0.53),
"transitions": PackedFloat32Array(1, 1), [sub_resource type="CurveTexture" id="CurveTexture_molrd"]
"values": [{ curve = SubResource("Curve_f5km5")
"args": [&"default", 1.0, false],
"method": &"play" [sub_resource type="Gradient" id="Gradient_76bi2"]
}, { colors = PackedColorArray(0, 0.9955722, 0.5778714, 1, 1, 0.9554942, 0.47369397, 1)
"args": [],
"method": &"hide" [sub_resource type="GradientTexture1D" id="GradientTexture1D_qcypm"]
}] gradient = SubResource("Gradient_76bi2")
}
[sub_resource type="Gradient" id="Gradient_ce4q1"]
colors = PackedColorArray(0.5254902, 1, 0.7294118, 1, 1, 1, 1, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_7q881"]
gradient = SubResource("Gradient_ce4q1")
[sub_resource type="Curve" id="Curve_pg3k8"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.5, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 3
[sub_resource type="CurveTexture" id="CurveTexture_tys76"]
curve = SubResource("Curve_pg3k8")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_v0dfw"]
particle_flag_disable_z = true
emission_shape = 1
emission_sphere_radius = 22.49
angle_min = 1.0728835e-05
angle_max = 360.00003
angle_curve = SubResource("CurveTexture_molrd")
direction = Vector3(-1, 0, 0)
spread = 60.0
initial_velocity_max = 2000.0
gravity = Vector3(0, 0, 0)
scale_min = 0.19999999
scale_max = 0.59999996
scale_curve = SubResource("CurveTexture_tys76")
color_ramp = SubResource("GradientTexture1D_7q881")
color_initial_ramp = SubResource("GradientTexture1D_qcypm")
alpha_curve = SubResource("CurveTexture_tu1jt")
[sub_resource type="AnimationLibrary" id="AnimationLibrary_l0pl0"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_l0pl0"]
_data = {
&"spawn": SubResource("Animation_kic6n")
}
[sub_resource type="SpriteFrames" id="SpriteFrames_qcypm"] [sub_resource type="SpriteFrames" id="SpriteFrames_l0pl0"]
animations = [{ animations = [{
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
@@ -65,24 +93,32 @@ animations = [{
"texture": ExtResource("9_76bi2") "texture": ExtResource("9_76bi2")
}], }],
"loop": false, "loop": false,
"name": &"default", "name": &"spawn",
"speed": 15.0 "speed": 20.0
}] }]
[node name="Parry" instance=ExtResource("1_vc7s4")] [node name="Parry" instance=ExtResource("1_vc7s4")]
spawnSound = "spawn" spawnSound = "spawn"
spawnAnimation = "spawn" spawnTexture = "spawn"
lockTexture = true
[node name="spawn" parent="sounds" index="0"] [node name="spawn" parent="sounds" index="0"]
stream = ExtResource("2_l0pl0") stream = ExtResource("2_l0pl0")
[node name="particles" parent="." index="1"]
texture = ExtResource("3_buxs5")
lifetime = 0.5
randomness = 1.0
process_material = SubResource("ParticleProcessMaterial_v0dfw")
[node name="animator" parent="stage" index="0"] [node name="animator" parent="stage" index="0"]
libraries = { libraries = {
&"": SubResource("AnimationLibrary_l0pl0") &"": SubResource("AnimationLibrary_l0pl0")
} }
[node name="texture" type="AnimatedSprite2D" parent="." index="3"] [node name="texture" parent="stage" index="1"]
modulate = Color(0.5254902, 1, 0.7294118, 1)
scale = Vector2(0.5, 0.5) scale = Vector2(0.5, 0.5)
sprite_frames = SubResource("SpriteFrames_qcypm") sprite_frames = SubResource("SpriteFrames_l0pl0")
frame = 7 frame = 7
frame_progress = 1.0 frame_progress = 1.0
+2 -1
View File
@@ -26,11 +26,12 @@ func hitBullet(bullet: BulletBase): # 当前子弹与其他子弹相撞
# 生成格挡特效 # 生成格挡特效
var eff = EffectController.create(ComponentManager.getEffect("Parry"), position + (bullet.position - position).normalized() * 200) # 从子弹位置,面向其他子弹的方向前进150 var eff = EffectController.create(ComponentManager.getEffect("Parry"), position + (bullet.position - position).normalized() * 200) # 从子弹位置,面向其他子弹的方向前进150
eff.modulate = bullet.modulate.blend(bullet.texture.modulate) eff.modulate = bullet.modulate.blend(bullet.texture.modulate)
eff.rotation = position.angle_to_point(bullet.position)
eff.shot() eff.shot()
# 摧毁其他子弹 # 摧毁其他子弹
bullet.tryDestroy() bullet.tryDestroy()
var cycler = launcher.getOrCreateCycleTimer("parry", 2000, 100) var cycler = launcher.getOrCreateCycleTimer("parry", 2000, 100)
if len(cycler.bullets) < maxBallCount: # 玩家最多只能拥有5点 if len(cycler.bullets) < maxBallCount: # 玩家最多只能拥有多少
for b in BulletBase.generate( for b in BulletBase.generate(
ComponentManager.getBullet("ParryBall"), # 生成气的子弹 ComponentManager.getBullet("ParryBall"), # 生成气的子弹
launcher, launcher,
+7 -3
View File
@@ -5,6 +5,7 @@ class_name EffectController
@export var spawnSound: String = "" @export var spawnSound: String = ""
@export var spawnAnimation: String = "" @export var spawnAnimation: String = ""
@export var spawnTexture: String = "" @export var spawnTexture: String = ""
@export var lockTexture: bool = false
@onready var particles: GPUParticles2D = $"%particles" @onready var particles: GPUParticles2D = $"%particles"
@onready var sounds: Node2D = $"%sounds" @onready var sounds: Node2D = $"%sounds"
@@ -15,6 +16,9 @@ func _ready():
register() register()
particles.emitting = false particles.emitting = false
particles.one_shot = oneShot particles.one_shot = oneShot
func _physics_process(_delta):
if lockTexture:
texture.global_rotation = 0
func shot(): func shot():
var childParticle = particles.duplicate() as GPUParticles2D var childParticle = particles.duplicate() as GPUParticles2D
childParticle.emitting = true childParticle.emitting = true
@@ -27,13 +31,13 @@ func shot():
if spawnTexture: if spawnTexture:
texture.play(spawnTexture) texture.play(spawnTexture)
if oneShot: if oneShot:
if childParticle.emitting:
await childParticle.finished
childParticle.queue_free()
if spawnTexture: if spawnTexture:
if texture.is_playing(): if texture.is_playing():
await texture.animation_finished await texture.animation_finished
texture.hide() texture.hide()
if childParticle.emitting:
await childParticle.finished
childParticle.queue_free()
if spawnSound: if spawnSound:
if sound.playing: if sound.playing:
await sound.finished await sound.finished