-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathMiniMap.js
55 lines (46 loc) · 1.26 KB
/
MiniMap.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
/**
* Created by Jerome Renaux (jerome.renaux@gmail.com) on 27-05-18.
*/
import Engine from './Engine'
import UI from './UI'
import WorldMap from './WorldMap'
function MiniMap(){
var r = 65;
var margin = 45;
var x = Engine.getGameConfig().width - r/2 - margin;
var y = r/2 + margin;
this.ring = UI.scene.add.sprite(x,y,'UI','mapring');
this.ring.setDepth(3);
this.ring.setScrollFactor(0);
this.ring.setVisible(false);
this.map = new WorldMap(x,y,r,r,0,0,true);
this.map.addMask(null,{
type: 'circle',
x: x,
y: y,
w: 133
});
var w = 150;
// var rect = UI.scene.add.rectangle(1024-w,0,w,w,0xffffff);
var rect = UI.scene.add.image(1024-w,0,'UI','invisible');
rect.setInteractive();
rect.setScrollFactor(0);
rect.setOrigin(0);
this.displayed = false;
}
MiniMap.prototype.follow = function(){
this.map.follow();
};
MiniMap.prototype.display = function(){
//if(this.bg) this.bg.setVisible(true);
this.ring.setVisible(true);
this.map.display();
this.displayed = true;
};
MiniMap.prototype.hide = function(){
//if(this.bg) this.bg.setVisible(false);
this.ring.setVisible(false);
this.map.hide();
this.displayed = false;
};
export default MiniMap