2021-07-21 15:37:53 +02:00
|
|
|
import { TextField } from "../Components/TextField";
|
2020-05-23 15:43:26 +02:00
|
|
|
import Image = Phaser.GameObjects.Image;
|
2020-05-23 16:13:37 +02:00
|
|
|
import Sprite = Phaser.GameObjects.Sprite;
|
2020-05-23 15:43:26 +02:00
|
|
|
|
|
|
|
export const ReconnectingSceneName = "ReconnectingScene";
|
|
|
|
enum ReconnectingTextures {
|
|
|
|
icon = "icon",
|
2021-07-21 15:37:53 +02:00
|
|
|
mainFont = "main_font",
|
2020-05-23 15:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export class ReconnectingScene extends Phaser.Scene {
|
2020-08-07 23:39:06 +02:00
|
|
|
private reconnectingField!: TextField;
|
|
|
|
private logo!: Image;
|
2020-05-23 15:43:26 +02:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super({
|
2021-07-21 15:37:53 +02:00
|
|
|
key: ReconnectingSceneName,
|
2020-05-23 15:43:26 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
preload() {
|
2021-07-20 16:45:24 +02:00
|
|
|
this.load.image(ReconnectingTextures.icon, "static/images/favicons/favicon-32x32.png");
|
2020-05-23 15:43:26 +02:00
|
|
|
// Note: arcade.png from the Phaser 3 examples at: https://github.com/photonstorm/phaser3-examples/tree/master/public/assets/fonts/bitmap
|
2021-07-21 15:37:53 +02:00
|
|
|
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 });
|
2020-05-23 15:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
create() {
|
2021-07-21 15:37:53 +02:00
|
|
|
this.logo = new Image(
|
|
|
|
this,
|
|
|
|
this.game.renderer.width - 30,
|
|
|
|
this.game.renderer.height - 20,
|
|
|
|
ReconnectingTextures.icon
|
|
|
|
);
|
2020-05-23 15:43:26 +02:00
|
|
|
this.add.existing(this.logo);
|
|
|
|
|
2021-07-21 15:37:53 +02:00
|
|
|
this.reconnectingField = new TextField(
|
|
|
|
this,
|
|
|
|
this.game.renderer.width / 2,
|
|
|
|
this.game.renderer.height / 2,
|
|
|
|
"Connection lost. Reconnecting..."
|
|
|
|
);
|
2020-05-23 16:13:37 +02:00
|
|
|
|
2021-07-21 15:37:53 +02:00
|
|
|
const cat = this.physics.add.sprite(this.game.renderer.width / 2, this.game.renderer.height / 2 - 32, "cat");
|
2020-05-23 16:13:37 +02:00
|
|
|
this.anims.create({
|
2021-07-21 15:37:53 +02:00
|
|
|
key: "right",
|
|
|
|
frames: this.anims.generateFrameNumbers("cat", { start: 6, end: 8 }),
|
2020-05-23 16:13:37 +02:00
|
|
|
frameRate: 10,
|
2021-07-21 15:37:53 +02:00
|
|
|
repeat: -1,
|
2020-05-23 16:13:37 +02:00
|
|
|
});
|
2021-07-21 15:37:53 +02:00
|
|
|
cat.play("right");
|
2020-05-23 15:43:26 +02:00
|
|
|
}
|
|
|
|
}
|