Skip to content

入门

http://book.phaser-china.com/INTRODUCTION.html

https://github.com/channingbreeze/phaser-tutorial

https://www.phaser-china.com/

https://github.com/photonstorm/phaser

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

https://phaser.io/

https://blog.xiiigame.com/2018-11-12-Phaser3%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/

https://developer.mozilla.org/zh-CN/docs/Games/Tutorials/2D_breakout_game_Phaser

文档

https://newdocs.phaser.io/

https://phaser.io/learn

https://phaser.io/tutorials/getting-started-phaser3

教程

https://phaser.io/learn/community-tutorials

https://phaser.io/tutorials/making-your-first-phaser-3-game-chinese

https://phaser.io/tutorials/getting-started-facebook-instant-games

模板

https://github.com/photonstorm/phaser3-project-template

https://github.com/photonstorm/phaser3-typescript-project-template

Game 类

https://newdocs.phaser.io/docs/3.54.0/Phaser.Game

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
var config = {
  type: Phaser.AUTO,
  width: 640,
  height: 480,
  backgroundColor: '#bfcc00',
  parent: 'phaser-example',
  scene: {
      preload: preload,
      create: create,
      update: update
  }
};

// https://photonstorm.github.io/phaser3-docs/Phaser.Types.Core.html#.GameConfig
var game = new Phaser.Game(config);

一个游戏对象,基本代表了游戏的所有内容,H5 的游戏一般会附着在一个 DOM 节点上,然后通过 canvas 或者 webgl 渲染出来

scale 属性

https://newdocs.phaser.io/docs/3.54.0/Phaser.Game#scale

https://newdocs.phaser.io/docs/3.54.0/Phaser.Scale.ScaleManager

phaser3-examples/public/src/scalemanager

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
let game = new Phaser.Game({
  type: Phaser.AUTO,
  scale: {
      mode: Phaser.Scale.FIT,
      parent: 'phaser-example',
      autoCenter: Phaser.Scale.CENTER_BOTH,
      width: 800,
      height: 600
  },
  physics: {
      default: 'arcade',
      arcade: {
          gravity: { y: 300 },
          debug: false
      }
  },
  scene: GameScene
})

Phaser.Types.Core.GameConfig

https://newdocs.phaser.io/docs/3.54.0/Phaser.Types.Core.GameConfig

在这里配置 scene

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
let game = new Phaser.Game({
  type: Phaser.AUTO,
  width: 640,
  height: 480,
  backgroundColor: '#bfcc00',
  parent: 'phaser-example',
  scene: {
      preload: preload,
      create: create,
      update: update
  }
})

示例项目

斗地主: https://github.com/mailgyc/doudizhu

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

https://phaser.io/examples/v3

全屏控制

https://phaser.io/examples/v3/view/scalemanager/full-screen-game

phaser3-examples/public/src/scalemanager/full screen game.js

竖屏提示

phaser3-examples/public/src/scalemanager/orientation check.js

扑克相关

https://www.emanueleferonato.com/2020/08/20/html5-deck-of-cards-management-updated-to-phaser-3/