白鷺中的資源加載,能夠單個去加載。可是更可能是經過資源組加載的。spa
好比進入登陸界面,則加載登陸資源組的資源。銷燬登陸界面,則卸載登陸模資源。3d
//加載登陸模塊資源組 RES.loadGroup("login"); //卸載登陸模塊資源組 RES.destroyRes("login");
那麼Laya是怎麼加載資源組呢?code
Laya加載單個資源blog
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加載資源組 class
Laya.loader.load(Laya.Loader.groupMap["login"]);
Laya卸載資源組登錄
Laya.loader.clearResByGroup("login");
用Scene.open打開場景時,會自動加載當前場景所需資源。List
源碼bin/libs/laya.core.js中,在使用Scene.open打開場景時,會在加載場景完成後,調用SceneLoader加載場景的loadList資源。這裏的loadList就是上圖預加載設置的資源。im
源碼bin/libs/laya.core.js中,在使用Scene.open時,會使用showLoadingPage做爲加載等待頁面
當加載場景以及場景預加載資源完成後,纔會打開場景,而且關閉等待加載頁面。