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



©xgqfrms 2012-2025

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

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


posted @   xgqfrms  阅读(130)  评论(4编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
历史上的今天:
2021-08-05 css overflow bug All In One
2021-08-05 Windows 系统不区分文件名大小写 bug All In One
2021-08-05 Apple MBP 无法链接 AirPods 2 耳机 All In One
2020-08-05 .pyc & Python
2020-08-05 How to change Linux Terminal display username All In One
2020-08-05 SVG image tag
2020-08-05 Python Learning Paths
点击右上角即可分享
微信分享提示