Spaces:
Running
Running
File size: 1,561 Bytes
4ee4376 |
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 74 75 76 77 78 79 80 81 82 83 |
export default class actor {
constructor (options) {
this.scene = options.scene;
this.common = this.scene.sys.game.common;
this.sprite = undefined;
this.cell = undefined;
this.depth = 10000;
this.tick = 0; // current tick
this.tickFrequency = 10; // how often to update
this.x = 0;
this.y = 0;
this.z = 0;
}
spawn () {
return;
}
update () {
}
sleep () {
}
wake () {
}
hide () {
}
show () {
}
destroy () {
this.sprites = [];
}
calculatePosition () {
this.offset = 0;
this.x = this.cell.position.bottom.x - (this.tile.width / 2) << 0;
this.y = this.cell.position.bottom.y - (this.tile.height) - this.offset << 0;
}
getTile (tileId) {
if (!this.common.tiles[tileId])
return false;
tileId = this.common.tiles[tileId].rotate[this.scene.city.cameraRotation];
return this.common.tiles[tileId];
}
create () {
this.calculatePosition();
if (this.tile.frames > 1)
this.sprite = this.scene.add.sprite(this.x, this.y, this.common.tilemap).play(this.tile.image);
else
this.sprite = this.scene.add.sprite(this.x, this.y, this.common.tilemap, this.tile.textures[0]);
//console.log(this.sprite);
this.sprite.cell = this.cell;
this.sprite.type = this.type;
this.sprite.setScale(this.common.scale);
this.sprite.setOrigin(0, 0);
this.sprite.setDepth(this.cell.depth + this.depth + (this.tile.depthAdjustment || 0));
}
addSprite (sprite) {
this.sprites.push(sprite);
}
} |