phaser3 微信小游戏若干问题
用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 微信小游戏若干问题的更多相关文章
- phaser3 微信小游戏入门
phaser与eget, laya, pixi.js本质上没什么区别. 都是渲染引擎. 其它的都是配角. phaser的特点是.代码容易理解 功能比较全面. 个人比较喜欢phaser的地方 twe ...
- Egret白鹭开发微信小游戏排行榜功能
推荐阅读: 我的CSDN 我的博客园 QQ群:704621321 我的个人博客 最近事情特别多,今天终于实现了排行榜功能,记录下来大家一起学习学习. 一.调用默认排行榜 首先我们需要了解: 1.白鹭开 ...
- 没玩过这些微信小游戏你就out了
你确定没玩过下面这些微信小游戏?是不是有点out了?赶紧添加微信号kangfuyk,回复H5马上畅玩! 当然了,扫一下二维码关注后回复H5更快捷噢! 微信小游戏列表,持续更新中 辨色大比拼!心理游戏 ...
- 【转】微信小游戏接入Fundebug监控
在SegmentFault上看到Fundebug上线小游戏监控,刚好最近开始玩微信小游戏,于是尝试接入试了一下. 接入方法 创建项目的时候选择左下角的微信小游戏图标. 点击继续进入接入插件页面. 第三 ...
- 【转】Fundebug上线微信小游戏错误监控!支持自动截屏!
摘要: Fundebug竭诚为你的小游戏保驾护航. 想必大家都玩过"跳一跳"吧?刷排行榜的感觉是不是很好啊!还有"知乎答题王"呢,在智力上碾压老铁简直太棒了! ...
- 【转】利用 three.js 开发微信小游戏的尝试
前言 这是一次利用 three.js 开发微信小游戏的尝试,并不能算作是教程,只能算是一篇笔记吧. 微信 WeChat 6.6.1 开始引入了微信小游戏,初期上线了一批质量相当不错的小游戏.我在查阅各 ...
- 微信小游戏开发之四:使用three.js引擎
一.前言 微信小游戏中最魔性的'跳一跳'就是基于three.js 引擎开发的 源码放到github上了:GitHub地址 请自行下载. 二.下载 three.min.js 打开页面,复制代码到本地 ...
- 微信小游戏开发Canvas资源汇总
Demo: 微信小程序demo组件:股票分时图 微信小程序小组件:仿直播点赞气泡效果,基于Canvas 优质demo推荐:二维码生成器:使用canvas与纯JS版二维码生成 微信小程序学习用完整dem ...
- 微信小游戏爆款秘笈 数据库MongoDB攻略篇
欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由腾讯云数据库 TencentDB 发表于云+社区专栏 随着微信小游戏的爆发,越来越多开发者关注到MongoDB与小游戏业务的契合度. ...
随机推荐
- 数据结构与算法之有序数组(2)——in dart
本文比第一篇,采用了类实现.增加了运算符重载等功能.本来有序数组是不能修改某个位置的值的,因为这样会打破数组的有序性:但为了演示,保留了修改的方法,但为此增加了排序. import 'dart:mat ...
- postgresql 安装插件
最近由于工作需要,学习了citusdata 插件,在按照官方文档装好postgresql 之后,不能在psql 中正常启用其它插件 如 : "create extension pg_trg ...
- PL/SQL轻量版(二)——基本语法
一.流程控制 1.条件判断 语法: IF <布尔表达式> THEN PL/SQL 和 SQL语句 END IF; IF <布尔表达式> THEN PL/SQL 和 SQL语句 ...
- 20155215 2016-2017-2 《Java程序设计》第3周学习总结
20155215 2016-2017-2 <Java程序设计>第3周学习总结 教材学习内容总结 第四章 第四章主要讲了类的构建,数组对象,字符串对象的构建与操作等.要学会区分基本类型与类类 ...
- day6 角点检测
1.Harris角点检测 # coding=utf-8 import cv2 import numpy as np filename = 'pic5.png' #1.读入一个灰度图像 img = cv ...
- MySQL入门篇(六)之mysqldump备份和恢复
一.备份单个数据库 1.备份命令:mysqldump MySQL数据库自带的一个很好用的备份命令.是逻辑备份,导出 的是SQL语句.也就是把数据从MySQL库中以逻辑的SQL语句的形式直接输出或生成备 ...
- PHPStrom 里修改Emmet对php的自动扩展
PHPStrom 7.1.3 Emmet 想必大家都比较清楚了.Emmet有个特点,对于匹配不到的符号,仍然会自动扩展为标签的形式,比如我输入aaaa,然后按tab,会自动扩展为<aaaa> ...
- python根据正则表达式的简单爬虫
今天根据正则表达式简单的爬了一下大众点评,把北京的美食爬了爬,(店铺名,人均消费,地址) import re import urllib.request from urllib.request imp ...
- Keil出错解决方法
1.安装KEIL5后创建工程后出现这个报错 解决方法:打开下图目录的文件. Keil.STM32F1xx_DFP.pdsc文件是只读文件,必须将只读属性取消. 如下图所示,注释掉红色圆圈的哪一行,保存 ...
- Linux 安装Zookeeper<单机版>(使用Mac远程访问)
阅读本文需要先阅读安装Zookeeper<准备> 新建目录 mkdir /usr/local/zookeeper 解压 cd zookeeper压缩包所在目录 tar -xvf zooke ...