Prettifying lost connection screen

This commit is contained in:
David Négrier 2020-05-23 16:13:37 +02:00
parent 36858f8747
commit e41eda9979
2 changed files with 19 additions and 3 deletions

View File

@ -341,12 +341,10 @@ export class Connexion implements ConnexionInterface {
disconnectServer(): void {
this.socket.on(EventMessage.CONNECT_ERROR, () => {
MessageUI.warningMessage("Trying to connect!");
this.GameManager.switchToDisconnectedScene();
});
this.socket.on(EventMessage.RECONNECT, () => {
MessageUI.removeMessage();
this.connectSocketServer();
this.GameManager.reconnectToGameScene(this.lastPositionShared);
});

View File

@ -6,6 +6,7 @@ import Image = Phaser.GameObjects.Image;
import Rectangle = Phaser.GameObjects.Rectangle;
import {PLAYER_RESOURCES} from "../Entity/PlayableCaracter";
import {cypressAsserter} from "../../Cypress/CypressAsserter";
import Sprite = Phaser.GameObjects.Sprite;
export const ReconnectingSceneName = "ReconnectingScene";
enum ReconnectingTextures {
@ -16,6 +17,7 @@ enum ReconnectingTextures {
export class ReconnectingScene extends Phaser.Scene {
private reconnectingField: TextField;
private logo: Image;
private cat: Sprite;
constructor() {
super({
@ -27,12 +29,28 @@ export class ReconnectingScene extends Phaser.Scene {
this.load.image(ReconnectingTextures.icon, "resources/logos/tcm_full.png");
// Note: arcade.png from the Phaser 3 examples at: https://github.com/photonstorm/phaser3-examples/tree/master/public/assets/fonts/bitmap
this.load.bitmapFont(ReconnectingTextures.mainFont, 'resources/fonts/arcade.png', 'resources/fonts/arcade.xml');
this.load.spritesheet(
'cat',
'resources/characters/pipoya/Cat 01-1.png',
{frameWidth: 32, frameHeight: 32}
);
}
create() {
this.logo = new Image(this, this.game.renderer.width - 30, this.game.renderer.height - 20, ReconnectingTextures.icon);
this.add.existing(this.logo);
this.reconnectingField = new TextField(this, 10, this.game.renderer.height - 35, "Connection lost. Reconnecting...");
this.reconnectingField = new TextField(this, this.game.renderer.width / 2, this.game.renderer.height / 2, "Connection lost. Reconnecting...");
this.reconnectingField.setOrigin(0.5, 0.5).setCenterAlign();
let cat = this.physics.add.sprite(this.game.renderer.width / 2, this.game.renderer.height / 2 - 32, 'cat');
this.anims.create({
key: 'right',
frames: this.anims.generateFrameNumbers('cat', { start: 6, end: 8 }),
frameRate: 10,
repeat: -1
});
cat.play('right');
}
}