用phasr3开发微信小游戏的话, 需要修改源码的地方不多。

1:微信小游戏不支持xml,需要装个DOMParser   http://club.phaser-china.com/topic/5b1276a0484a53dd723f42ff

2:图片加载方式需要修改,不好重写代码,需要修改源码

var ImageFile = new Class({

    Extends: File,

    initialize:

    function ImageFile (loader, key, url, xhrSettings, frameConfig)
{
this.isWX = typeof wx !== "undefined";
var extension = 'png';
var normalMapURL; if (IsPlainObject(key))
{
var config = key; key = GetFastValue(config, 'key');
url = GetFastValue(config, 'url');
normalMapURL = GetFastValue(config, 'normalMap');
xhrSettings = GetFastValue(config, 'xhrSettings');
extension = GetFastValue(config, 'extension', extension);
frameConfig = GetFastValue(config, 'frameConfig');
} if (Array.isArray(url))
{
normalMapURL = url[1];
url = url[0];
} var fileConfig = {
type: 'image',
cache: loader.textureManager,
extension: extension,
responseType: 'arraybuffer',
key: key,
url: url,
xhrSettings: xhrSettings,
config: frameConfig
}; File.call(this, loader, fileConfig); // Do we have a normal map to load as well?
if (normalMapURL)
{
var normalMap = new ImageFile(loader, this.key, normalMapURL, xhrSettings, frameConfig); normalMap.type = 'normalMap'; this.setLink(normalMap); loader.addFile(normalMap);
}
}, /**
* Called automatically by Loader.nextFile.
* This method controls what extra work this File does with its loaded data.
*
* @method Phaser.Loader.FileTypes.ImageFile#onProcess
* @since 3.7.0
*/
onProcess: function ()
{
let url = this.__url;
this.state = CONST.FILE_PROCESSING; this.data = new Image(); this.data.crossOrigin = this.crossOrigin; var _this = this; this.data.onload = function ()
{
if (!this.isWX) {
File.revokeObjectURL(_this.data);
_this.onProcessComplete();
} else {
this.addToCache();
}
}; this.data.onerror = function ()
{
if (!this.isWX) {
File.revokeObjectURL(_this.data);
} else {
console.log("||||||");
}
_this.onProcessError();
}; if (this.isWX) {
this.data.src = url;
} else {
File.createObjectURL(this.data, this.xhrLoader.response, 'image/png');
}
}, /**
* Adds this file to its target cache upon successful loading and processing.
*
* @method Phaser.Loader.FileTypes.ImageFile#addToCache
* @since 3.7.0
*/
addToCache: function ()
{
var texture;
var linkFile = this.linkFile; if (linkFile && linkFile.state === CONST.FILE_COMPLETE)
{
if (this.type === 'image')
{
texture = this.cache.addImage(this.key, this.data, linkFile.data);
}
else
{
texture = this.cache.addImage(linkFile.key, linkFile.data, this.data);
} this.pendingDestroy(texture); linkFile.pendingDestroy(texture);
}
else if (!linkFile)
{
texture = this.cache.addImage(this.key, this.data); this.pendingDestroy(texture);
}
}  }); 

3: 边界面部导致微信小游戏的点击事件失效, window.pageXOffset为undefined 修改源码或修改适配器都可以

    updateBounds: function ()
{
var bounds = this.bounds; var clientRect = this.canvas.getBoundingClientRect(); bounds.x = clientRect.left + (window.pageXOffset - document.documentElement.clientLeft || 0);
bounds.y = clientRect.top + (window.pageYOffset - document.documentElement.clientTop || 0);
bounds.width = clientRect.width;
bounds.height = clientRect.height;
},

phaser3 微信小游戏若干问题的更多相关文章

  1. phaser3 微信小游戏入门

    phaser与eget, laya, pixi.js本质上没什么区别. 都是渲染引擎.  其它的都是配角.  phaser的特点是.代码容易理解 功能比较全面. 个人比较喜欢phaser的地方 twe ...

  2. Egret白鹭开发微信小游戏排行榜功能

    推荐阅读: 我的CSDN 我的博客园 QQ群:704621321 我的个人博客 最近事情特别多,今天终于实现了排行榜功能,记录下来大家一起学习学习. 一.调用默认排行榜 首先我们需要了解: 1.白鹭开 ...

  3. 没玩过这些微信小游戏你就out了

    你确定没玩过下面这些微信小游戏?是不是有点out了?赶紧添加微信号kangfuyk,回复H5马上畅玩! 当然了,扫一下二维码关注后回复H5更快捷噢! 微信小游戏列表,持续更新中 辨色大比拼!心理游戏 ...

  4. 【转】微信小游戏接入Fundebug监控

    在SegmentFault上看到Fundebug上线小游戏监控,刚好最近开始玩微信小游戏,于是尝试接入试了一下. 接入方法 创建项目的时候选择左下角的微信小游戏图标. 点击继续进入接入插件页面. 第三 ...

  5. 【转】Fundebug上线微信小游戏错误监控!支持自动截屏!

    摘要: Fundebug竭诚为你的小游戏保驾护航. 想必大家都玩过"跳一跳"吧?刷排行榜的感觉是不是很好啊!还有"知乎答题王"呢,在智力上碾压老铁简直太棒了! ...

  6. 【转】利用 three.js 开发微信小游戏的尝试

    前言 这是一次利用 three.js 开发微信小游戏的尝试,并不能算作是教程,只能算是一篇笔记吧. 微信 WeChat 6.6.1 开始引入了微信小游戏,初期上线了一批质量相当不错的小游戏.我在查阅各 ...

  7. 微信小游戏开发之四:使用three.js引擎

    一.前言 微信小游戏中最魔性的'跳一跳'就是基于three.js 引擎开发的 源码放到github上了:GitHub地址   请自行下载. 二.下载 three.min.js 打开页面,复制代码到本地 ...

  8. 微信小游戏开发Canvas资源汇总

    Demo: 微信小程序demo组件:股票分时图 微信小程序小组件:仿直播点赞气泡效果,基于Canvas 优质demo推荐:二维码生成器:使用canvas与纯JS版二维码生成 微信小程序学习用完整dem ...

  9. 微信小游戏爆款秘笈 数据库MongoDB攻略篇

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由腾讯云数据库 TencentDB 发表于云+社区专栏 随着微信小游戏的爆发,越来越多开发者关注到MongoDB与小游戏业务的契合度. ...

随机推荐

  1. css中元素的分类

    按照显示元素分类: 行内元素(lnline-element):元素的高度,行高,顶底边距由元素所包含的图片或文字所决定,不可改变:其宽度为内容文字或图片的宽度所决定,而其左右边距可人为设置. 行内元素 ...

  2. Eclipse怎么恢复默认界面

    Eclipse里面将界面恢复到默认状态: 1.选择Eclipse的工具栏里面的“窗口(Window)”,找到“复位透视图(Reset Perspective)”选项: 2.单击“复位透视图(Reset ...

  3. ubuntu装openVPN会遇到的问题

    与Windows系统相比,Linux下安装OpenVPN的过程就显得有点曲折. 如果你使用的是Ubuntu系统,你可以直接使用命令sudo apt-get install -y openvpn来安装O ...

  4. Android开发——LinearLayout和RelativeLayout的性能对比

    0. 前言 我们都知道新建一个Android项目自动生成的Xml布局文件的根节点默认是RelativeLayout,这不是IDE默认设置,而是由android-sdk\tools\templates\ ...

  5. 通过redis实现session共享-php

    <?php class redisSession{ /** * 保存session的数据库表的信息 */ private $_options = array( 'handler' => n ...

  6. 二、Web框架实现

    一.简单web(socket) 在前一篇WEB框架概述一文中已经详细了解了:从浏览器键入一个URL到返回HTML内容的整个过程.说到底,本质上其实就是一个socket服务端,用户的浏览器其实就是一个s ...

  7. SQL创建数据库、建表、填入内容

    --创建数据库 create database Information go --使用数据库 use Information go --创建表 create table Student ( Sno ) ...

  8. 11-Dockerfile构建镜像

    用 Dockerfile 创建上节的 ubuntu-with-vi,其内容则为: FROM ubuntu RUN apt-get update && apt-get install v ...

  9. 算法工程师进化-NLP之主题模型

    1 引言 主题模型是文本挖掘的重要工具,近年来在学术界和工业届都获得了非常多的关注.学术界的工作主要集中在建模层面,即提出各种各样的主题模型来适应不同的场景,因此缺乏指导主题模型在工业场景落地的资源和 ...

  10. spring-boot断点调试(IDEA)