首先引入游戏框架 phaser.min.js
<script src="phaser.min.js"></script>
然后引入游戏代码 catch-the-cat.js
<script src="catch-the-cat.js"></script>
然后在指定的 div 中新建一个游戏的 canvas,并开始游戏
<div id="catch-the-cat"></div>
<script>
window.game = new CatchTheCatGame({
w: 11,
h: 11,
r: 20,
backgroundColor: 0xeeeeee,
parent: 'catch-the-cat',
statusBarAlign: 'center',
credit: 'github.com/ganlvtech'
});
</script>
参数列表:
参数 | 值 | 说明 |
---|---|---|
w | 11 |
横向格子数 |
h | 11 |
竖向格子数 |
r | 20 |
圆半径像素 |
非必选参数:
参数 | 值 | 说明 |
---|---|---|
backgroundColor | 0xeeeeee |
背景颜色 |
parent | catch-the-cat |
父元素的 id 或 DOM 对象 |
statusBarAlign | center |
状态栏左对齐 left 或居中 center |
credit | github.com/ganlvtech |
右下角的备注信息 |
参考 src/solvers/
中提供的例子编写算法,并使用下列代码替换。
window.game.solver = yourSolver;
这个 solver 的返回值即为猫要往哪个方向走一步,如果撞墙则算玩家获胜
值 | 说明 |
---|---|
-1 | 猫主动弃权 |
0 | 左 |
1 | 左上 |
2 | 右上 |
3 | 右 |
4 | 右下 |
5 | 左下 |
猫站在星号的位置,数字代表每个方向的编号
1 2
0 * 3
5 4
例如
window.game.solver = function (blocksIsWall, i, j) {
return 0;
};
即:一直向左走,直到撞墙。
MIT License
运行阶段性并发任务 Java 并发 API 提供的一个非常复杂且强大的功能是,能够使用Phaser类运行阶段性的并发任务。当某些并发任务是分成多个步骤来执行时,那么此机制是非常有用的。Phaser类提供的机制是在每个步骤的结尾同步线程,所以除非全部线程完成第一个步骤,否则线程不能开始进行第二步。 相对于其他同步应用,我们必须初始化Phaser类与这次同步操作有关的任务数,我们可以通过增加或者减少来
Phaser 是一个快速、免费、有趣的开源HTML5游戏框架,在桌面和移动网络浏览器上提供WebGL和Canvas渲染功能。游戏可以通过使用第三方工具编译成iOS、Android和本地应用程序。你可以使用JavaScript或TypeScript进行开发。
IonPhaser Web Component built with Stencil.js to integrate Phaser with any other framework. Inspired by the old IonPhaser directive Demo Do you want to see this web component in action? Visit https://
Phaser 2 Examples Looking for Phaser 3 Examples? They are in their own repo. Phaser v2 is a fast, free and fun open source HTML5 game framework. It uses Pixi.js for WebGL and Canvas rendering across d
Phaser CE (Community Edition) Phaser CE is a fast, free, and fun open source HTML5 game framework. It uses a custom build of Pixi.js for WebGL and Canvas rendering, and supports desktop and mobile web
expo-phaser Tools for using Phaser-ce to build native 2D games in Expo �� Installation Usage Functions Example Demo Installation yarn add expo-phaser Usage Import the library into your JavaScript file
Phaser 3 TypeScript Starter Template A starter template for Phaser 3 with TypeScript and webpack for building excellent html5-games that work great in the browser and on mobile devices. Key Features •