This commit is contained in:
dgflash
2024-03-02 17:59:09 +08:00
parent f099446867
commit 69143c205b
2 changed files with 18 additions and 5 deletions

View File

@@ -42,7 +42,7 @@ export class AudioManager extends Component {
}
/** 循环播放背景音乐 */
playerMusicLoop(url: string) {
playMusicLoop(url: string) {
if (this._switch_music) {
this.music.loop = true;
this.music.load(url);

View File

@@ -13,7 +13,11 @@ import { ViewUtil } from "../../core/utils/ViewUtil";
const { ccclass } = _decorator;
/** 游戏显示对象组件模板 */
/**
* 游戏显示对象组件模板
* 1、当前对象加载的资源会在对象释放时自动释放引用的资源
* 2、当前对象支持启动游戏引擎提供的各种常用逻辑事件
*/
@ccclass("GameComponent")
export class GameComponent extends Component {
//#region 全局事件管理
@@ -180,16 +184,25 @@ export class GameComponent extends Component {
//#region 音频播放管理
/**
* 循环播放背景音乐 - 音频资源会在对象释放时自动释放
* 播放背景音乐
* @param url 资源地址
*/
playMusic(url: string) {
this.resPaths.set(url, oops.res.defaultBundleName);
oops.audio.playerMusicLoop(url);
oops.audio.playMusic(url);
}
/**
* 播放音效 - 音频资源会在对象释放时自动释放
* 循环播放背景音乐
* @param url 资源地址
*/
playMusicLoop(url: string) {
this.resPaths.set(url, oops.res.defaultBundleName);
oops.audio.playMusicLoop(url);
}
/**
* 播放音效
* @param url 资源地址
*/
playEffect(url: string) {