-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathRemains.js
51 lines (40 loc) · 1.25 KB
/
Remains.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
/**
* Created by Jerome Renaux (jerome.renaux@gmail.com)
*/
import CustomSprite from './CustomSprite'
import Engine from './Engine'
import Utils from '../shared/Utils'
import World from '../shared/World'
var Remains = new Phaser.Class({
Extends: CustomSprite,
initialize: function Remains() {
CustomSprite.call(this, 'Engine', 0, 0);
// this.setInteractive();
this.entityType = 'remain';
},
setUp: function(data){
this.setTexture('remains');
var frameMap = {
0: 'wolf',
1: 'human'
};
this.setFrame(frameMap[data.type]);
this.setVisible(true);
this.setTilePosition(data.x,data.y,true);
this.setOrigin(0.5,0);
this.updateDepth();
if(Utils.randomInt(0,10) > 5) this.flipX = true;
this.x += World.tileWidth/2;
this.y += World.tileHeight/2;
Engine.remains[this.id] = this;
Engine.entityManager.addToDisplayList(this);
},
updateDepth: function(){
this.setDepth(this.tileY+1.5); // for e.g. when wood spawns on the roots of a tree
},
remove: function(){
CustomSprite.prototype.remove.call(this);
delete Engine.remains[this.id];
}
});
export default Remains