Laya商業級3d實戰 014聲音模組

2021-10-09 05:11:06 字數 2205 閱讀 7966

laya商業級3d遊戲開發

方法原形

laya.soundmanager.playsound(資源位址);

匯入素材layaide\sound到laya\bin\res\目錄下

注意:考慮到多平台相容性,聲音和音效建議都使用***格式

新建scripts\manager\soundmgr.ts

\方便呼叫的資料結構

//方便呼叫的資料結構

export class audioclip

public play()

private static minstance: soundmgr

public static get instance()

readonly bgmurl = 'res/sound/main/bgm.***';

readonly bgmurl2 = 'res/sound/game/bgm.***';

readonly clcik = new audioclip('res/sound/main/click.***', 0);

readonly fishcollection = new audioclip('res/sound/game/fishcollection.***', 0.5);

readonly catdeath = new audioclip('res/sound/game/catdeath.***', 1);

constructor()

static isplaysound(): boolean

static setplaysound(isplaysound: boolean)

curbgm_soundchannel: laya.soundchannel;

onad_video_close_event()

play(url: string)

playoneshot(url: string)

}bgmplay()

playgamebgm()

bgmplaysetting()

/**後台從前台恢復聲音 */

public resumebgm()

}public pausebgm()

prebgmurl = "";

playbgm(url: string, loop: boolean)

else

this.curbgm_soundchannel.play();}}

首頁新增聲音控制按鈕

型別imgage

新建uicomponent/btn/soundbtn.ts

export default class soundbtn extends laya.image

onclick() btnsound runtime 掛上指令碼

homeview.ts

onopened

soundmgr.instance.bgmplay();

viewmgr.ts

public openhome(callder, callbackfunc: function) ));gamesample.ts

新增public static gotohome()

遊戲場景加入聲音

game.ts

onawake()

soundmgr.instance.playgamebgm();

playereatfish() 

_regisiterwxcallback()

onwxshowevent(res)

onaudiointerruptionend(res)

拷貝素材下的platform.ts檔案到platform目錄

補齊gamesample {

public static commondata:commondata=new commondata();

初始化平台資訊

main.ts

onconfigloaded()增加

Laya商業級3d實戰 07動畫系統

laya商業級3d遊戲開發 開啟u3d 下的example animator場景並且匯出 注意事項 動畫匯出注意事項 型別動畫需要設定為genneric,不支援人形骨骼humanoid 動畫片段不要出現空幀,否則個別平台會出現載入錯誤 比如 回到laya ide 新建example03 animat...

3D網路實戰學習 網路基礎(一)

目前辭職在家,疫情期間也找不到工作,正好看到了一本書 3d網路遊戲實戰 趁機學習一下網路知識,希望在此期間能找個遊戲公司收留我qaq。先說網路遊戲大多是基於tcp ip協議的bs 客戶端 伺服器 結構,客戶端執行在使用者的電腦或手機上,服務端執行在遊戲運營商的伺服器上,如圖 在實現網路傳輸時,人們把...

XNA 的 3D 和 2D 遊戲引擎(商業與開源)

找到了不少,在這裡分享一下。說不定以後我自己也要用到!商業3d引擎 torquex 我兩年前用的時候,還只是乙個2d引擎,目前社群版已經有for xna 4.0 的了 visual3d 這個沒有用過,不過看介紹還是不錯 開源3d引擎 oxgameengine fox xna 社群裡推薦的遊戲引擎,似...