basic login page with a text input and a click button
This commit is contained in:
parent
33bcbd4650
commit
d691b58d0b
9 changed files with 107 additions and 25 deletions
24
front/src/Phaser/Components/TextInput.ts
Normal file
24
front/src/Phaser/Components/TextInput.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
export class TextInput extends Phaser.GameObjects.Text {
|
||||
constructor(scene: Phaser.Scene, x: number, y: number) {
|
||||
super(scene, x, y, '', { fontSize: '32px', fontStyle: 'Courier', color: '#fff'});
|
||||
this.scene.add.existing(this);
|
||||
|
||||
|
||||
let keySpace = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE);
|
||||
let keyBackspace = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.BACKSPACE);
|
||||
this.scene.input.keyboard.on('keydown', (event: any) => {
|
||||
if (event.keyCode === 8 && this.text.length > 0) {
|
||||
this.text = this.text.substr(0, this.text.length - 1);
|
||||
} else if (event.keyCode === 32 || (event.keyCode >= 48 && event.keyCode < 90)) {
|
||||
this.text += event.key;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getText(): string {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue