phaser2 微信小游戏入手
phaser2小游戏基本没什么什么问题,可以下常开发游戏.如果遇到什么问题, 可以提出来共同讨论.
下面来个例子
import './lib/weapp-adapter';
import Phaser from './lib/phaser'; let systemInfo = wx.getSystemInfoSync();
let {windowWidth, windowHeight, pixelRatio} = systemInfo; var config = {
width: windowWidth * pixelRatio,
height: windowHeight * pixelRatio,
renderer: Phaser.WEBGL,
antialias: true,
multiTexture: true,
resolution:1,
canvas:canvas
} let game = new Phaser.Game(config);
game.state.add("boot", Boot, true); function Boot() { } Boot.prototype.preload = function() {
game.input.scale.x = pixelRatio;
game.input.scale.y = pixelRatio;
this.load.baseURL = "assets/";
game.load.image("crate", "crate.png");
} Boot.prototype.create = function() {
// adding P2 physics to the game
game.physics.startSystem(Phaser.Physics.P2JS);
// setting gravity
game.physics.p2.gravity.y = 250;
// adding event listener for mousedown/touch event
game.input.onDown.add(this.addRemove, this);
} Boot.prototype.addRemove = function(pointer){
// checking for bodies under the mouse
var bodyClicked = game.physics.p2.hitTest(pointer.position);
if (bodyClicked.length==0){
// creation of physics body and its graphic asset
var crate = game.add.sprite(pointer.position.x, pointer.position.y, "crate");
game.physics.p2.enable(crate);
}
else{
// destruction of physics body and its graphic asset
bodyClicked[0].parent.sprite.kill();
}
};
基于一般的全屏小游戏的宽高是640,高度是动态的.这里也是需要做下处理的
import './lib/weapp-adapter';
import Phaser from './lib/phaser'; let systemInfo = wx.getSystemInfoSync();
let {windowWidth, windowHeight, pixelRatio} = systemInfo;
let width = 640;
let height = 640 * windowHeight / windowWidth; var config = {
width,
height,
renderer: Phaser.WEBGL,
antialias: true,
multiTexture: true,
resolution:1,
canvas:canvas
} let game = new Phaser.Game(config);
game.state.add("boot", Boot, true); function Boot() { } Boot.prototype.preload = function() {
game.input.scale.x = config.width / windowWidth;
game.input.scale.y = config.height / windowHeight;
this.load.baseURL = "assets/";
game.load.image("crate", "crate.png");
} Boot.prototype.create = function() {
// adding P2 physics to the game
game.physics.startSystem(Phaser.Physics.P2JS);
// setting gravity
game.physics.p2.gravity.y = 250;
// adding event listener for mousedown/touch event
game.input.onDown.add(this.addRemove, this);
} Boot.prototype.addRemove = function(pointer){
// checking for bodies under the mouse
var bodyClicked = game.physics.p2.hitTest(pointer.position);
if (bodyClicked.length==0){
// creation of physics body and its graphic asset
var crate = game.add.sprite(pointer.position.x, pointer.position.y, "crate");
game.physics.p2.enable(crate);
}
else{
// destruction of physics body and its graphic asset
bodyClicked[0].parent.sprite.kill();
}
};
phaser开发小游戏一点问题都没,笔者已经用phaser开发三款小游戏。没有遇到什么大问题...
声音的话,sound.play方法,然后用wx的播放声音的方法代替.
github: https://gitee.com/redw1234567/phaser-ce
有问题留言或 QQ群 881784250. 谢谢~~~
phaser2 微信小游戏入手的更多相关文章
- pixi.js 微信小游戏 入手
pixi是什么?一款h5游戏引擎 优点:简单简洁性能第一 缺点:大多数用的国产三大引擎,pixi资料少,工具少, 为什么学,装逼 用pixi开发小游戏行吗? 行.但要简单处理下 下载官网上的 weap ...
- 没玩过这些微信小游戏你就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与小游戏业务的契合度. ...
- Egret 生成 自带EUI 的微信小游戏 踩坑!
1. 首先,再次被网上一大堆屎一样的资料搞得浪费了我一天时间.各种坑. 2. 本文先讲一种正确的方式,然后再列举坑. 去www.egret.com下载最新的引擎,我的最新版本是5.2.2. 然后就会被 ...
随机推荐
- dotnet Core 2.0学习笔记(一)
一:Dotnet Core Windows运行环境,标红部分要注意 https://docs.microsoft.com/en-us/dotnet/core/windows-prerequisites ...
- 2016-2017-2 《Java程序设计》第1周学习问题汇总
201552-53 <Java程序设计>第一周问题汇总 关于软件安装以及配置中出现的问题,附上教程及讨论组网址: JDK/intelljIDEA安装及配置: http://www.cnbl ...
- 20155232 实验一《Java开发环境的熟悉》实验报告
20155232 实验一<Java开发环境的熟悉>实验报告 实验内容 使用JDK编译.运行简单的Java程序: 使用Eclipse 编辑.编译.运行.调试Java程序 实验要求 没有Lin ...
- sqlite3日期数据类型
一.sqlite3日期数据类型,默认用datetime解析(根据stackflow) 使用时注意三点: 1. 创建表时,字段 DT 的类型为 date 2. 插入数据时,DT字段直接为 str 类型 ...
- 【RAC搭建报错】libcap.so.1:cannot open shared object file
原文参考:http://blog.csdn.net/siyanyanyanyai/article/details/45306595 http://orax.blog.sohu.com/26207226 ...
- 前端 CDNJS 库及 Google Fonts、Ajax 和 Gravatar 国内加速服务
由于某些众所周知的原因,好多开源的 JS 库采用的国外 CDN 托管方式在国内访问速度不如人意.所以我们特意制作了这个公益项目,托管了 CDNJS 的所有开源 JS 库以及反代了 Google Fon ...
- 在腾讯云上安装mysql遇到的问题
卸载mysql: 1.sudo apt-get autoremove --purge mysql-server-5.5 5.5 是数据库版本, mysql -v 显示版本信息 2.sudo apt-g ...
- java.lang.Boolean.valueOf(String s)
简单说,就是s为true(这四个字母大小写任意)时,返回值为true,否则为false public class one { public static void main(String[] args ...
- dubbo 微服务框架
dubbo 注解配置: @Service //Service注解暴露服务 @Configuration // javaconfig形式配置公共模块 @DubboComponentScan // 指定d ...
- MATLAB 笔记
MATLAB的学习 Matlab 主要有5大部分构成,分别是MATLAB语言,桌面工具与开发环境,数学函数库 ,图形系统和应用程序接口.以及众多的专业工具.