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();
    }
    }

  • 相关阅读:
    项目人力资源管理
    以太网交换机
    邮件协议简单学习
    信息系统开发方法
    项目成本管理
    oracle学习笔记002---oracle的体系结构
    007 项目进度管理
    乘法逆元
    RMQ __ST
    中国剩余定理(CRT)
  • 原文地址:https://www.cnblogs.com/honghong87/p/15091111.html
Copyright © 2011-2022 走看看