-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvirus.js
33 lines (28 loc) · 860 Bytes
/
virus.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
'use strict';
var Virus = function(x, y, type) {
Phaser.Sprite.call(this, game, x, y, 'viruses', 0);
this.variant = type;
if (type === colorVariant.RED) {
this.frame = 0;
} else if (type === colorVariant.BLUE) {
this.frame = 1;
} else if (type === colorVariant.GREEN) {
this.frame = 2;
}
if (type === colorVariant.RED) {
this.animations.add('main', [0, 3, 6, 9], 12, true);
} else if (type === colorVariant.BLUE) {
this.animations.add('main', [1, 4, 7, 10], 12, true);
} else if (type === colorVariant.GREEN) {
this.animations.add('main', [2, 5, 8, 11], 12, true);
}
this.animations.play('main');
groups.viruses.add(this);
};
Virus.prototype = Object.create(Phaser.Sprite.prototype);
Virus.prototype.constructor = Virus;
Virus.prototype.update = function() {
if (!this.alive) {
this.destroy();
}
};