feat(英雄/怪物): 添加受击倒地特效

- 新增 down.prefab 和 down.anim 资源文件
- 在 Hero 和 Monster 的落地逻辑中调用 playEnd("down") 播放特效
- 优化 HeroViewComp 中特效生成逻辑,移除冗余的组件销毁操作
This commit is contained in:
walkpan
2026-03-23 20:23:37 +08:00
parent ef7f76952f
commit 849a8aeaef
7 changed files with 762 additions and 4 deletions

View File

@@ -0,0 +1,309 @@
[
{
"__type__": "cc.AnimationClip",
"_name": "down",
"_objFlags": 0,
"__editorExtras__": {
"embeddedPlayerGroups": []
},
"_native": "",
"sample": 60,
"speed": 1,
"wrapMode": 1,
"enableTrsBlending": false,
"_duration": 0.3,
"_hash": 500763545,
"_tracks": [
{
"__id__": 1
},
{
"__id__": 7
}
],
"_exoticAnimation": null,
"_events": [],
"_embeddedPlayers": [],
"_additiveSettings": {
"__id__": 13
},
"_auxiliaryCurveEntries": []
},
{
"__type__": "cc.animation.ObjectTrack",
"_binding": {
"__type__": "cc.animation.TrackBinding",
"path": {
"__id__": 2
},
"proxy": null
},
"_channel": {
"__id__": 5
}
},
{
"__type__": "cc.animation.TrackPath",
"_paths": [
{
"__id__": 3
},
{
"__id__": 4
},
"spriteFrame"
]
},
{
"__type__": "cc.animation.HierarchyPath",
"path": "Node"
},
{
"__type__": "cc.animation.ComponentPath",
"component": "cc.Sprite"
},
{
"__type__": "cc.animation.Channel",
"_curve": {
"__id__": 6
}
},
{
"__type__": "cc.ObjectCurve",
"_times": [
0,
0.016666666666666666,
0.03333333333333333,
0.05,
0.06666666666666667,
0.08333333333333333,
0.1,
0.11666666666666667,
0.13333333333333333,
0.15,
0.16666666666666666,
0.18333333333333332,
0.2,
0.21666666666666667,
0.23333333333333334,
0.25,
0.26666666666666666,
0.2833333333333333
],
"_values": [
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@52b6b",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@4a656",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@896a7",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@d762c",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@4d618",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@92b2b",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@9aaec",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@0f9dd",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@d3d4c",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@959e0",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@ab228",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@9ebea",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@e6ae3",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@eff40",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@589ea",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@7ae5c",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@92cb2",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@8ec34",
"__expectedType__": "cc.SpriteFrame"
}
]
},
{
"__type__": "cc.animation.ObjectTrack",
"_binding": {
"__type__": "cc.animation.TrackBinding",
"path": {
"__id__": 8
},
"proxy": null
},
"_channel": {
"__id__": 11
}
},
{
"__type__": "cc.animation.TrackPath",
"_paths": [
{
"__id__": 9
},
{
"__id__": 10
},
"spriteFrame"
]
},
{
"__type__": "cc.animation.HierarchyPath",
"path": "Node-001"
},
{
"__type__": "cc.animation.ComponentPath",
"component": "cc.Sprite"
},
{
"__type__": "cc.animation.Channel",
"_curve": {
"__id__": 12
}
},
{
"__type__": "cc.ObjectCurve",
"_times": [
0,
0.016666666666666666,
0.03333333333333333,
0.05,
0.06666666666666667,
0.08333333333333333,
0.1,
0.11666666666666667,
0.13333333333333333,
0.15,
0.16666666666666666,
0.18333333333333332,
0.2,
0.21666666666666667,
0.23333333333333334,
0.25,
0.26666666666666666,
0.2833333333333333
],
"_values": [
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@52b6b",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@4a656",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@896a7",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@d762c",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@4d618",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@92b2b",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@9aaec",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@0f9dd",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@d3d4c",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@959e0",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@ab228",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@9ebea",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@e6ae3",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@eff40",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@589ea",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@7ae5c",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@92cb2",
"__expectedType__": "cc.SpriteFrame"
},
{
"__uuid__": "3d46f945-3f07-477e-a95a-b49557d552c6@8ec34",
"__expectedType__": "cc.SpriteFrame"
}
]
},
{
"__type__": "cc.AnimationClipAdditiveSettings",
"enabled": false,
"refClip": null
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "2.0.3",
"importer": "animation-clip",
"imported": true,
"uuid": "33a2e81d-ecfe-4b0f-a566-52205e9be285",
"files": [
".cconb"
],
"subMetas": {},
"userData": {
"name": "down"
}
}

View File

@@ -0,0 +1,425 @@
[
{
"__type__": "cc.Prefab",
"_name": "down",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "down",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 8
}
],
"_active": true,
"_components": [
{
"__id__": 14
},
{
"__id__": 16
},
{
"__id__": 18
}
],
"_prefab": {
"__id__": 20
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "Node",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_prefab": {
"__id__": 7
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 0.3,
"y": 0.5,
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 4
},
"_contentSize": {
"__type__": "cc.Size",
"width": 127,
"height": 127
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ddhDbko4FLmKZGY46brX7z"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 6
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "c3vPZUzCRINL3sICnCZKIr"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "feOW1uSctLKYCw3esMiuox",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "Node-001",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 9
},
{
"__id__": 11
}
],
"_prefab": {
"__id__": 13
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": -0.3,
"y": 0.5,
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 8
},
"_enabled": true,
"__prefab": {
"__id__": 10
},
"_contentSize": {
"__type__": "cc.Size",
"width": 127,
"height": 127
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "55YW07+pBBsrB+bmUz7LbN"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 8
},
"_enabled": true,
"__prefab": {
"__id__": 12
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "563lW4y8dOKKb6uUa3O6O7"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "ad2xHCtTNATotpdPSpd/Sl",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 15
},
"_contentSize": {
"__type__": "cc.Size",
"width": 104,
"height": 75
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a7pn5tzA1BSI1AfdpVsHh7"
},
{
"__type__": "cc.Animation",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 17
},
"playOnLoad": true,
"_clips": [
{
"__uuid__": "33a2e81d-ecfe-4b0f-a566-52205e9be285",
"__expectedType__": "cc.AnimationClip"
}
],
"_defaultClip": {
"__uuid__": "33a2e81d-ecfe-4b0f-a566-52205e9be285",
"__expectedType__": "cc.AnimationClip"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "63z5ZyjTNKYbn+kEVB1s3W"
},
{
"__type__": "0f3c4JhFbFO2rEFqBJJ7hFv",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 19
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "32SLcINL1JHZ+vIyextzaC"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "cfqCWnxbFLNoQMedQXsav3",
"instance": null,
"targetOverrides": null
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "1586073b-28db-40e7-8fa2-8ea0cd86c1ea",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "down"
}
}

View File

@@ -105,6 +105,7 @@ export class Hero extends ecs.Entity {
.call(() => {
if (!node || !node.isValid) return;
node.setPosition(pos.x, dropToY, 0);
hv.playEnd("down");
move.moving = true;
if (collider) {
collider.enabled = true;

View File

@@ -334,8 +334,6 @@ export class HeroViewComp extends CCComp {
private spawnTimedFx(path: string, parent: Node | null, life: number = 0.8, worldPos?: Vec3): Node | null {
const node = this.createFxNode(path, parent, worldPos);
if (!node) return null;
const ender = node.getComponent(oneCom);
if (ender) ender.destroy();
const timer = node.getComponent(timedCom) || node.addComponent(timedCom);
timer.time = Math.max(0.2, life);
return node;
@@ -343,8 +341,6 @@ export class HeroViewComp extends CCComp {
private spawnAnimEndFx(path: string, parent: Node | null, worldPos?: Vec3): Node | null {
const node = this.createFxNode(path, parent, worldPos);
if (!node) return null;
const timer = node.getComponent(timedCom);
if (timer) timer.destroy();
node.getComponent(oneCom) || node.addComponent(oneCom);
return node;
}

View File

@@ -171,6 +171,7 @@ export class Monster extends ecs.Entity {
.call(() => {
if (!node || !node.isValid) return;
node.setPosition(pos.x, dropToY, 0);
view.playEnd("down");
move.moving = true;
if (collider) {
collider.enabled = true;