feat(audio): 优化攻击音效播放机制
- 将攻击音效播放延迟0.5秒以匹配动画时机 - 移除攻击音效的循环播放设置 - 注释掉攻击音效的停止逻辑,让音效自然播放完成
This commit is contained in:
@@ -2358,7 +2358,7 @@
|
|||||||
"__uuid__": "5d1cb41c-cc52-4f72-abf1-04e6b5e26278",
|
"__uuid__": "5d1cb41c-cc52-4f72-abf1-04e6b5e26278",
|
||||||
"__expectedType__": "cc.AudioClip"
|
"__expectedType__": "cc.AudioClip"
|
||||||
},
|
},
|
||||||
"_loop": true,
|
"_loop": false,
|
||||||
"_playOnAwake": false,
|
"_playOnAwake": false,
|
||||||
"_volume": 1,
|
"_volume": 1,
|
||||||
"_id": "73BrdnBedC5Yy6rg1H7I4I"
|
"_id": "73BrdnBedC5Yy6rg1H7I4I"
|
||||||
|
|||||||
@@ -988,11 +988,13 @@ export class PlayerController extends Component {
|
|||||||
|
|
||||||
// 播放攻击音效
|
// 播放攻击音效
|
||||||
if (this.attackAudio) {
|
if (this.attackAudio) {
|
||||||
const audioSource = this.attackAudio.getComponent(AudioSource);
|
this.scheduleOnce(() => {
|
||||||
if (audioSource) {
|
const audioSource = this.attackAudio.getComponent(AudioSource);
|
||||||
audioSource.play();
|
if (audioSource) {
|
||||||
console.log('播放攻击音效');
|
audioSource.play();
|
||||||
}
|
console.log('播放攻击音效');
|
||||||
|
}
|
||||||
|
}, 0.5)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取玩家动画组件
|
// 获取玩家动画组件
|
||||||
@@ -1016,13 +1018,13 @@ export class PlayerController extends Component {
|
|||||||
this.isAttacking = false;
|
this.isAttacking = false;
|
||||||
|
|
||||||
// 停止攻击音效
|
// 停止攻击音效
|
||||||
if (this.attackAudio) {
|
// if (this.attackAudio) {
|
||||||
const audioSource = this.attackAudio.getComponent(AudioSource);
|
// const audioSource = this.attackAudio.getComponent(AudioSource);
|
||||||
if (audioSource) {
|
// if (audioSource) {
|
||||||
audioSource.stop();
|
// audioSource.stop();
|
||||||
console.log('停止攻击音效');
|
// console.log('停止攻击音效');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user