-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (60 loc) · 1.74 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import Phaser from 'phaser'
import DisplayListWatcher from './src/main'
function stringToColor(str) {
let hash = 5381
for (let i = 0; i < str.length; i++) {
hash = (hash * 33) ^ str.charCodeAt(i)
}
return hash >>> (0 % 0xffffff)
}
class Example extends Phaser.Scene {
init() {
this.cameras
.add(512, 384, 512, 384)
.setAngle(45)
.setAlpha(0.5)
.setBackgroundColor(stringToColor(this.sys.settings.key))
.centerOn(0, 0)
}
preload() {}
create() {
this.add.blitter(0, 0, '__DEFAULT').create(0, 0)
this.add.container(0, 0, [this.add.container(0, 0, this.add.container())])
this.add.layer([this.add.layer(this.add.layer())])
this.add.particles(0, 0, '__DEFAULT')
this.add.zone(0, 0, 1, 1)
this.add.text(0, 0, '👀', { font: '72px sans-serif' }).setName('eyes')
const tilemap = this.make.tilemap({ data: [[0]] })
const tileset = tilemap.addTilesetImage('__DEFAULT')
tilemap.createLayer(0, tileset)
tilemap.createBlankLayer(1, tileset).setName('blank')
for (let i = 0; i < 100 * this.scene.getIndex(this); i++) {
this.add.zone(i, i)
}
this.add.zone(0, 0).setName('end')
}
}
new Phaser.Game({
// type: Phaser.CANVAS,
plugins: {
scene: [
{
key: 'DisplayListWatcher',
plugin: DisplayListWatcher,
start: true
}
]
},
scene: [
new Example({ key: '1 active', active: true }),
new Example({ key: '2 active', active: true }),
new Example({ key: '3 inactive', active: false }),
new Example({ key: '4 active', active: true }),
new Example({
key: '5 no other plugins',
active: true,
plugins: ['DisplayListWatcher']
}),
new Example({ key: '6 active', active: true })
]
})