Skip to content

Sence类

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

load 属性

https://newdocs.phaser.io/docs/3.54.0/Phaser.Scene#load

https://newdocs.phaser.io/docs/3.55.2/Phaser.Loader.LoaderPlugin

image 方法

https://newdocs.phaser.io/docs/3.55.2/Phaser.Loader.LoaderPlugin#image

1
2
3
function preload() {
    this.load.image('logo', 'images/phaserLogo.png')
}

atlas 方法

https://newdocs.phaser.io/docs/3.55.2/Phaser.Loader.LoaderPlugin#atlas

1
2
3
4
5
6
function preload() {
    this.load.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json');
}
function preload () {
  this.load.atlas('cards', 'cards.png', 'cards.json');
}

spritesheet 方法

https://newdocs.phaser.io/docs/3.55.2/Phaser.Loader.LoaderPlugin#spritesheet

1
2
3
function preload() {
    this.load.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 })
}

scale 属性

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

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

add 属性

https://newdocs.phaser.io/docs/3.54.0/Phaser.Scene#add

text 方法:
https://newdocs.phaser.io/docs/3.55.2/Phaser.GameObjects.GameObjectFactory#text

1
2
3
4
5
6
this.scoreText = this.add.text(16, 16, 'score: 0', { fontSize: '32px', fill: '#000' });

this.score += 10;   
this.scoreText.setText('Score: ' + this.score);  

this.add.text(100, 400, 'Phaser').setFontFamily('Arial').setFontSize(64).setColor('#ffff00');

image 方法:
https://newdocs.phaser.io/docs/3.55.2/Phaser.GameObjects.GameObjectFactory#image
返回值: Phaser.GameObjects.Image: https://newdocs.phaser.io/docs/3.55.2/Phaser.GameObjects.Image

setInteractive:
https://newdocs.phaser.io/docs/3.55.2/Phaser.GameObjects.Image#setInteractive
返回值: Phaser.GameObjects.Image

sprite 方法:

1
2
3
4
5
6
7
8
function preload() {
    this.load.spritesheet('aliens', 'assets/sprites/bsquadron-enemies.png', { frameWidth: 192, frameHeight: 160 });
}
function create () {
    for (let i = 0; i < 4; i ++) {
       this.add.sprite(100 + i * 146, 100 + i * 142, 'aliens', i).setInteractive();
    }
}

graphics 方法:

input 属性

https://newdocs.phaser.io/docs/3.54.0/Phaser.Scene#input

https://newdocs.phaser.io/docs/3.55.2/Phaser.Input.InputPlugin

on 方法

https://newdocs.phaser.io/docs/3.55.2/Phaser.Input.InputPlugin#on

tweens 属性

https://newdocs.phaser.io/docs/3.54.0/Phaser.Scene#tweens

https://newdocs.phaser.io/docs/3.55.2/Phaser.Tweens.TweenManager

add 方法

https://newdocs.phaser.io/docs/3.55.2/Phaser.Tweens.TweenManager#add

textures 属性

https://newdocs.phaser.io/docs/3.54.0/Phaser.Scene#textures

texture:
n. 质地,纹理;口感;(音乐或文学的)谐和统一感,神韵 v. 使(织物、墙面等)具浮凸结构(或特征)

frame:
n. 框架,边框;(家具、建筑物、车辆等的)构架,支架;体格,骨架;眼镜框;(系统、概念或文章的)基本框架;镜头,画面;(连环漫画中的)一幅画;(网页的)一个区域;(斯诺克或保龄球的)一局;(玻璃或塑料的箱式)轻便温床;(纺织、编结或刺绣用的)框;替换框架
v. 装框架;勾勒出;围绕;<非正式>陷害,诬陷;制定,拟订;(措词谨慎地)表达 adj. 有木架的

https://newdocs.phaser.io/docs/3.55.2/Phaser.Textures.TextureManager

1
2
3
var frames = this.textures.get('cards').getFrameNames();
// https://newdocs.phaser.io/docs/3.55.2/Phaser.Textures.TextureManager#get
// https://newdocs.phaser.io/docs/3.52.0/Phaser.Textures.Texture#getFrameNames

time 属性

https://newdocs.phaser.io/docs/3.54.0/Phaser.Scene#time