-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspotlight_rect.js
74 lines (60 loc) · 1.62 KB
/
spotlight_rect.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
72
73
var config = {
type: Phaser.WEBGL,
parent: 'phaser-example',
width: 800,
height: 600,
scene: {
preload: preload,
create: create,
}
};
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('pic', 'assets/backgrounds/taikodrummaster.jpg');
this.load.image('mask', 'assets/sprites/ultrasound_beam.png');
this.load.image('probe', 'assets/sprites/probe.png');
this.load.spritesheet('speckle',
'assets/sprites/speckle.png',
{ frameWidth: 80, frameHeight: 101 });
this.load.image('logo', 'assets/sprites/phaser.png');
}
function create ()
{
this.add.image(100, 60, 'logo');
var pic = this.add.image(400, 300, 'pic');
var spotlight = this.make.sprite({
x: 800,
y: 1010,
key: 'mask',
add: false
});
var probe = this.make.sprite({
x: 800,
y: 1010,
key: 'probe',
add: true
});
var speckle = this.make.sprite({
x: 800,
y: 1010,
key: 'speckle',
add: true
});
this.anims.create({
key: 'speckle_cycle',
frames: this.anims.generateFrameNumbers('speckle', { start: 0, end: 9 }),
frameRate: 10,
repeat: -1
});
pic.mask = new Phaser.Display.Masks.BitmapMask(this, spotlight);
this.input.on('pointermove', function (pointer) {
spotlight.x = pointer.x;
spotlight.y = pointer.y;
probe.x = pointer.x;
probe.y = pointer.y;
speckle.x = pointer.x;
speckle.y = pointer.y;
speckle.anims.play('speckle_cycle', true)
});
}