xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Phaser.js All In One

Phaser.js All In One

HTML5 Canvas 2D Game Engine

image

Phaser.js

https://phaser.io/

https://phaserjs.com/

Phaser 3

https://github.com/photonstorm/phaser

https://www.npmjs.com/package/phaser

https://github.com/photonstorm/phaser3-examples

$ yarn add -D phaser

$ npm i phaser

Phaser CE / Phaser 2

https://github.com/photonstorm/phaser-ce

https://www.npmjs.com/package/phaser-ce

$ yarn add -D phaser-ce

$ npm i phaser-ce

https://github.com/photonstorm/phaser-ce/tree/master/typescript

https://github.com/photonstorm/phaser-ce#webpack

https://github.com/lean/phaser-es6-webpack

PixiJS

The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.

https://pixijs.com

https://github.com/pixijs/pixijs

demos

const log = console.log;

log('Hello Phaser.js 👻');

log(`\nPhaser =`, Phaser);
// Phaser = {VERSION: '2.19.2', GAMES: Array(0), AUTO: 0, CANVAS: 1, WEBGL: 2, …}
log(`Phaser.AUTO =`, Phaser.AUTO);
// 0

var game = new Phaser.Game(375, 667, Phaser.AUTO);

var gameState = {
  preload: function () {
    game.stage.backgroundColor = '#a8d4bf';
    game.load.image('logo', './imgs/logo.png');
  },
  create: function () {
    // var text = game.add.text(game.world.centerX, 25, 'first demo', {fill: '#fff'});
    var text = game.add.text(game.world.centerX, 25, 'first demo', {fill: '#0f0'});
    text.anchor.set(0.5);
    var img = game.add.image(game.world.centerX, game.world.centerY, 'logo');
    // 居中
    img.anchor.set(0.5);
    // 左上方,偏移
    // img.anchor.set(0.7);
    // 右下方,偏移
    // img.anchor.set(0.3);
  },
};

game.state.add('gameState', gameState);

game.state.start('gameState');


docs

https://photonstorm.github.io/phaser-ce/

https://github.com/photonstorm/phaser-ce/tree/master/docs

https://github.com/photonstorm/phaser-ce/blob/master/DOCS.md

https://github.com/photonstorm/phaser-ce/issues/726

微信适配版

源码构建

// globalThis ???

typeof GameGlobal
// 'undefined'

GameGlobal
// Uncaught ReferenceError: GameGlobal is not defined ❌

https://gitee.com/codeveryday/phaser-ce_wechat/commit/a9315a54245a1b280cd12a337114130298167098

refs

http://phaser.io/learn

sandbox

http://phaser.io/sandbox

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-08-05 12:55  xgqfrms  阅读(125)  评论(4编辑  收藏  举报