mirror of
https://github.com/OpenLiberty/liberty-bikes.git
synced 2025-02-23 11:19:12 +08:00
Fix bug where turning into a wall and dying didn't display the fatal direction change
This commit is contained in:
parent
472793ab21
commit
1c5580dc32
@ -11,13 +11,16 @@ export class Player {
|
||||
public x: number;
|
||||
public y: number;
|
||||
public image: Bitmap;
|
||||
public explosionImage: Bitmap;
|
||||
public tooltip: PlayerTooltip;
|
||||
direction: string;
|
||||
|
||||
public update(x: number, y: number, direction: string) {
|
||||
//console.log(`[Player-${this.name}] x=${x} y=${y} direction=${direction}`);
|
||||
let playerMoved: boolean = (this.x !== x) || (this.y !== y);
|
||||
let playerMoved: boolean = (this.x !== x) || (this.y !== y) || (this.direction !== direction);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.direction = direction;
|
||||
if (!this.tooltip)
|
||||
this.tooltip = new PlayerTooltip(this);
|
||||
if (!this.image) {
|
||||
@ -49,16 +52,17 @@ export class Player {
|
||||
|
||||
public visible(isVisible: boolean) {
|
||||
this.image.visible = isVisible;
|
||||
this.explosionImage.visible = isVisible;
|
||||
this.tooltip.visible(isVisible);
|
||||
}
|
||||
|
||||
public setStatus(status: string) {
|
||||
if (status === 'Dead' && this.status !== 'Dead') {
|
||||
this.image = Assets.PLAYER_DEAD_BITMAP.clone();
|
||||
this.image.scaleX = 1.2;
|
||||
this.image.scaleY = 1.2;
|
||||
this.image.x = this.x - 20;
|
||||
this.image.y = this.y - 20;
|
||||
if (status === 'Dead' && this.status !== 'Dead' && !this.explosionImage) {
|
||||
this.explosionImage = Assets.PLAYER_DEAD_BITMAP.clone();
|
||||
this.explosionImage.scaleX = 1.2;
|
||||
this.explosionImage.scaleY = 1.2;
|
||||
this.explosionImage.x = this.x - 16;
|
||||
this.explosionImage.y = this.y - 16;
|
||||
if (!Player.audioLoaded) {
|
||||
Player.audioLoaded = true;
|
||||
Assets.BAM.load();
|
||||
@ -69,15 +73,17 @@ export class Player {
|
||||
}
|
||||
|
||||
public addTo(stage: Stage) {
|
||||
if (this.tooltip) {
|
||||
if (this.tooltip)
|
||||
stage.addChild(this.tooltip.tooltipShape);
|
||||
}
|
||||
stage.addChild(this.image);
|
||||
if (this.explosionImage)
|
||||
stage.addChild(this.explosionImage);
|
||||
}
|
||||
public removeFrom(stage: Stage) {
|
||||
if (this.tooltip) {
|
||||
if (this.tooltip)
|
||||
stage.removeChild(this.tooltip.tooltipShape);
|
||||
}
|
||||
if (this.explosionImage)
|
||||
stage.removeChild(this.explosionImage);
|
||||
stage.removeChild(this.image);
|
||||
}
|
||||
}
|
||||
|
@ -125,8 +125,7 @@ export class GameComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
this.players.set(playerInfo.id, newPlayer);
|
||||
|
||||
if (playerInfo.status !== 'Dead')
|
||||
newPlayer.update(playerInfo.x * Constants.BOX_SIZE, playerInfo.y * Constants.BOX_SIZE, playerInfo.direction);
|
||||
newPlayer.update(playerInfo.x * Constants.BOX_SIZE, playerInfo.y * Constants.BOX_SIZE, playerInfo.direction);
|
||||
|
||||
newPlayer.addTo(this.stage);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user