Slash-The-Hordes/assets/Scripts/Utils/UIButtonAudioPlayer.ts

18 lines
613 B
TypeScript
Raw Normal View History

2022-12-22 12:26:43 +00:00
import { Component, _decorator } from "cc";
import { AppRoot } from "../AppRoot/AppRoot";
import { UIButton } from "../Services/UI/Button/UIButton";
const { ccclass, property } = _decorator;
@ccclass("UIButtonAudioPlayer")
export class UIButtonAudioPlayer extends Component {
@property(UIButton) private button: UIButton;
public start(): void {
this.button.InteractedEvent.on(this.playButtonClick, this);
}
private playButtonClick(): void {
const audioClip = AppRoot.Instance.GameAssets.AudioAssets.buttonClick;
AppRoot.Instance.AudioPlayer.playSound(audioClip);
}
}