zoukankan      html  css  js  c++  java
  • phaser3微信小游戏2

    之前介绍过phaser3微信小游戏适配(只需2步)

    添加微信小游戏适配器(官网上下载最新的weapp-adapter即可)

    修改phaser加载image的方式需要修改(由于微信小游戏不支持blob)

    添加适配器就不用说了,修改加载image的加载方式(重写是最好的,当然也可以改源码,然后编译)

    // wechat适配器的performance的存在问题,不应该除以1000
    window.performance.now = function() {
    return Date.now()
    };

    Phaser.Loader.File.prototype.defload = Phaser.Loader.File.prototype.load;

    Phaser.Loader.File.prototype.onLoad = function (xhr, event) {
    var localFileOk = ((xhr.responseURL && xhr.responseURL.indexOf('file://') === 0 && xhr.status === 0));
    var success = !(xhr && xhr.status !== 200) || localFileOk;
    if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599){
    success = false;
    }
    this.state = 12;
    this.resetXHR();
    this.loader.nextFile(this, success);
    }

    Phaser.Loader.File.prototype.load = function() {
    if (this.type == "image") {
    this.data = new Image();
    let self = this;
    this.data.onload = function() {
    self.state = 12;
    self.loader.inflight.delete(self);
    self.loader.totalComplete++;
    self.loader.queue.set(self);
    self.loader.emit("load", self);
    self.onProcessComplete();
    }
    let src = this.url;
    this.data.src = src;
    } else {
    this.defload();
    }
    }

  • 相关阅读:
    自定义Dialog
    AlertDialog
    Toast
    WebView
    《构建之法》阅读笔记3
    UI组件之GridView
    ScrollView&HorizontalScrollView
    UI组件之ImageView
    UI组件之ListView
    每周总结(1.24)
  • 原文地址:https://www.cnblogs.com/honghong87/p/15091111.html
Copyright © 2011-2022 走看看