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与小游戏业务的契合度. ...
随机推荐
- golang 项目实战简明指南
原文地址 开发环境搭建 golang 的开发环境搭建比较简单,由于是编译型语言,写好 golang 源码后,只需要执行 go build 就能将源码编译成对应平台(本文中默认为 linux)上的可执行 ...
- 20155337 2016-2017-2 《Java程序设计》第一周学习总结
20155337 2016-2017-2 <Java程序设计>第一周学习总结 教材学习内容总结 我们主要学习的是JAVA SE平台也就是标准平台-Java SE四个组成部分:JVM .JR ...
- Oracle下如何用rman备份到特定的sequence
本文为摘抄,目的为方便日后阅读: http://docs.oracle.com/cd/B12037_01/server.101/b10734/rcmbackp.htm To determine the ...
- [BZOJ4444][SCOI2015]国旗计划-[ST表]
Description 传送门 Solution 说真的这道题在场上没做出来的我必定是脑子有洞.. 我们用st表记录以某个位置开始,派了1<<j个战士能到达的最远位置. 由于边境线是一圈, ...
- 2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 https://lydsy.com/JudgeOnline/problem.php?id=2288 分析: 贪心+堆+链表. 首先把序列变一下,把相 ...
- 使用Python的BeautifulSoup 类库采集网页内容
BeautifulSoup 一个分析.处理DOM树的类库.可以做网络爬虫.模块简称bs4. 安装类库 easy_install beautifulsoup4 pip install beautiful ...
- xpath基础
XML:一种可扩展标记语言,HTML就是一种XML XPATH:也是一个W3C标准,在所有XML中均可使用 XPATH的路径规则 /表示跟节点 /html 表示html这个元素 /html/body ...
- 简单读取 properties文件
看了网上很多读取的方法,都太过复杂,直接使用下面的方法就可以简单读取 properties文件了 ide使用idea 测试读取成功 import java.util.ResourceBundle; p ...
- 《图解 HTTP 》阅读 —— 第五章
第5章 与HTTP协作的web服务器 一台服务器可以托管多个域名. 在相同的IP地址下,虚拟主机可以寄存多个不同主机名和域名的网站,所以在发送HTTP请求时,必须在Host首部内指定完整的主机名和域名 ...
- 《Cocos2d-x游戏开发实战精解》学习笔记3--在Cocos2d-x中播放声音
<Cocos2d-x游戏开发实战精解>学习笔记1--在Cocos2d中显示图像 <Cocos2d-x游戏开发实战精解>学习笔记2--在Cocos2d-x中显示一行文字 之前的内 ...