Merge pull request #93 from aguibert/player-dead-image

Player go boom
This commit is contained in:
Andrew Guibert 2018-05-11 14:38:33 -05:00 committed by GitHub
commit 6485bf9b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -5,6 +5,7 @@ export class Player {
// According to EaselJS, "When a string path or image tag that is not yet loaded is used, the stage may need to be redrawn before the Bitmap will be displayed."
// For this reason, we need to pre-load an instance of the image (this copy never gets used)
static readonly PLAYER_BITMAP = new Bitmap('../../assets/images/bike_wide.png');
static readonly PLAYER_DEAD_BITMAP = new Bitmap('../../assets/images/status_dead.png');
public name: string;
public status: string;
@ -49,6 +50,17 @@ export class Player {
this.tooltip.visible(isVisible);
}
public setStatus(status: string) {
this.status = status;
if (status === 'Dead') {
this.image = new Bitmap('../../assets/images/status_dead.png');
this.image.scaleX = 0.7;
this.image.scaleY = 0.7;
this.image.x = this.x - 10;
this.image.y = this.y - 10;
}
}
public addTo(stage: Stage) {
if (this.tooltip) {
stage.addChild(this.tooltip.shape);

View File

@ -142,7 +142,7 @@ export class GameComponent implements OnInit, OnDestroy {
playerEntity.tooltip.alpha(1);
}
playerEntity.status = player.status;
playerEntity.setStatus(player.status);
});
if (noneAlive) {
this.players.forEach((player: Player, id: string) => {