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