-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathslot.js
More file actions
53 lines (43 loc) · 1.25 KB
/
slot.js
File metadata and controls
53 lines (43 loc) · 1.25 KB
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
var Dot = require('./dot');
var util = require('./util');
function Slot(groups, board, c, r) {
var _board = board;
this.row = r;
this.col = c;
this.popper = null;
if (r < 10) {
this.sprite = groups.slots.create(0, 0, 'square');
this.sprite.inputEnabled = true;
this.sprite.anchor.setTo(-0.03, -0.03);
this.sprite.scale.x = 0.5;
this.sprite.scale.y = 0.5;
this.sprite.events.onInputOver.add(function () {
_board.indicate(c, r);
}, this);
this.sprite.events.onInputOut.add(function () {
_board.clearIndication();
}, this);
this.sprite.events.onInputUp.add(function () {
_board.poke(c, r);
}, this);
var pos = util.getPosition(r, c);
this.sprite.x = pos.x;
this.sprite.y = pos.y;
}
this.dot = new Dot(groups, c, r);
this.dot.sprite.bringToTop();
this.showDot = function (show) {
this.dot.visible(show);
};
this.pop = function () {
if (this.popper !== null) {
this.popper.pop();
this.popper = null;
}
this.showDot(false);
};
}
Slot.load = function (game) {
game.load.image('square', 'square.png');
};
module.exports = Slot;