Laya的資源加載


白鷺中的資源加載,可以單個去加載。但是更多是通過資源組加載的。

比如進入登錄界面,則加載登錄資源組的資源。銷毀登錄界面,則卸載登錄模資源。

//加載登錄模塊資源組
RES.loadGroup("login");
//卸載登錄模塊資源組
RES.destroyRes("login");

  

那么Laya是怎么加載資源組呢?

 

Laya.loader加載資源

Laya加載單個資源

Laya.loader.load("res/atlas/anim.atlas");

Laya加載多個資源 

Laya.loader.load(["res/atlas/anim.atlas","res/atlas/chat.atlas"]);

Laya設置資源組

Laya.loader.setGroup("res/atlas/anim.atlas","login");
Laya.loader.setGroup("res/atlas/chat.atlas","login");

Laya加載資源組 

Laya.loader.load(Laya.Loader.groupMap["login"]); 

Laya卸載資源組

Laya.loader.clearResByGroup("login");

 

Scene.open加載資源

用Scene.open打開場景時,會自動加載當前場景所需資源。

 

 源碼bin/libs/laya.core.js中,在使用Scene.open打開場景時,會在加載場景完成后,調用SceneLoader加載場景的loadList資源。這里的loadList就是上圖預加載設置的資源。

 

 

源碼bin/libs/laya.core.js中,在使用Scene.open時,會使用showLoadingPage作為加載等待頁面

 

當加載場景以及場景預加載資源完成后,才會打開場景,並且關閉等待加載頁面。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM