zoukankan      html  css  js  c++  java
  • Laya微信小游戏的动态资源

    版本2.1.1.

    由于有4m包限制,所以一般小游戏项目分成主包+远程资源。

    现在我新建一个remote目录,该目录下资源不发布到微信小游戏目录下,而是服务器远程加载。

    发布时,勾线是否提取本地包

    远程资源目录remote不需要勾选

    这是发布出的项目有两个文件夹,其中wxgame是常规项目,wxgame_pack是不含remote文件夹的项目

     

    那么我们微信提交时,只需要提交主包wxgame_pack就行了。将remote资源放到服务器动态加载。

    平时我们使用remote的图片是这样的。加载remote.atlas图集,并显示其中test1.jpg

    Laya.loader.load("res/atlas/remote.atlas", Laya.Handler.create(this, ()=>{
         let sp:Laya.Sprite = new Laya.Sprite();
         sp.texture = Laya.loader.getRes("remote/test1.jpg");
         this.addChild(sp);
    }));
    

      

    Laya论坛有个方法。就是设置Url.basePath。这样load的每个路径都会自动加上basePath。

    比如我们的远程服务器路径是http://127.0.0.1:8011/wxgame/,如下图设置。

    MiniAdpter.nativefiles白名单里的资源只会从本地加载,而没有在名单里的资源都从远程服务器加载。

    Laya.URL.basePath = "http://127.0.0.1:8011/wxgame/";
     
    Laya["MiniAdpter"].nativefiles = [
          "wxlocal",
          "res/atlas/comp.atlas"
    ] 

    目前Laya这块有Bug。白名单并不是都生效。

  • 相关阅读:
    Automatic Setup of a Humanoid
    SLAM——视觉里程计(一)feature
    JSP和EL和JSTL
    rework-发出你的心声
    bootstrap单选框复选框的使用
    bootstrap输入框组
    vue中改变数组或对象,页面没做出对应的渲染
    bootstrap面板的使用
    bootstrap列表组的使用
    bootstrap表格的使用
  • 原文地址:https://www.cnblogs.com/gamedaybyday/p/11545390.html
Copyright © 2011-2022 走看看