Add image to report and to teleport player
This commit is contained in:
parent
8773989bbe
commit
c63fb6ed6f
5 changed files with 59 additions and 16 deletions
|
@ -46,6 +46,8 @@ export abstract class Character extends Container {
|
|||
public PlayerValue: string;
|
||||
public sprites: Map<string, Sprite>;
|
||||
private lastDirection: string = PlayerAnimationNames.WalkDown;
|
||||
private report: Sprite;
|
||||
private teleportation: Sprite;
|
||||
|
||||
constructor(scene: Phaser.Scene,
|
||||
x: number,
|
||||
|
@ -62,6 +64,15 @@ export abstract class Character extends Container {
|
|||
|
||||
for (const texture of textures) {
|
||||
const sprite = new Sprite(scene, 0, 0, texture, frame);
|
||||
sprite.setInteractive({useHandCursor: true});
|
||||
sprite.on('pointerover', () => {
|
||||
this.report.visible = true;
|
||||
this.teleportation.visible = true;
|
||||
});
|
||||
sprite.on('pointerup', () => {
|
||||
this.report.visible = true;
|
||||
this.teleportation.visible = true;
|
||||
});
|
||||
this.add(sprite);
|
||||
this.getPlayerAnimations(texture).forEach(d => {
|
||||
this.scene.anims.create({
|
||||
|
@ -76,6 +87,24 @@ export abstract class Character extends Container {
|
|||
this.sprites.set(texture, sprite);
|
||||
}
|
||||
|
||||
this.report = new Sprite(scene, 20, -10, 'report_flag', 3);
|
||||
this.report.setInteractive();
|
||||
this.report.visible = false;
|
||||
this.report.on('pointerup', () => {
|
||||
this.report.visible = false;
|
||||
this.teleportation.visible = false;
|
||||
});
|
||||
this.add(this.report);
|
||||
|
||||
this.teleportation = new Sprite(scene, -20, -10, 'teleportation', 3);
|
||||
this.teleportation.setInteractive();
|
||||
this.teleportation.visible = false;
|
||||
this.teleportation.on('pointerup', () => {
|
||||
this.report.visible = false;
|
||||
this.teleportation.visible = false;
|
||||
});
|
||||
this.add(this.teleportation);
|
||||
|
||||
this.PlayerValue = name;
|
||||
this.playerName = new BitmapText(scene, x, y - 25, 'main_font', name, 8);
|
||||
this.playerName.setOrigin(0.5).setCenterAlign().setDepth(99999);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue