Add more abilities and move contact flag

This commit is contained in:
Flashfyre committed 2023-04-27 14:30:03 -04:00
1 parent 18679241e9
commit 005cc9b7d5
10 files changed
+2596 -2077

No files matched your search

+16 -7
View File
@@ -2,6 +2,9 @@ import BattleScene from "../battle-scene";
import Pokemon from "../pokemon";
import { TextStyle, addTextObject } from "./text";
const hiddenX = -91;
const shownX = 10;
export default class AbilityBar extends Phaser.GameObjects.Container {
private bg: Phaser.GameObjects.Image;
private pokemonNameText: Phaser.GameObjects.Text;
@@ -12,7 +15,7 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
public shown: boolean;
constructor(scene: BattleScene) {
super(scene, -91, (-scene.game.canvas.height / 6) + 64);
super(scene, hiddenX, (-scene.game.canvas.height / 6) + 64);
}
setup(): void {
@@ -21,11 +24,11 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
this.add(this.bg);
this.pokemonNameText = addTextObject(this.scene, 5, 3, 'Pokemon', TextStyle.MESSAGE, { fontSize: '72px' });
this.pokemonNameText = addTextObject(this.scene, 5, 3, '', TextStyle.MESSAGE, { fontSize: '72px' });
this.pokemonNameText.setOrigin(0, 0);
this.add(this.pokemonNameText);
this.abilityNameText = addTextObject(this.scene, 87, 16, 'Chlorophyll', TextStyle.WINDOW, { fontSize: '72px' });
this.abilityNameText = addTextObject(this.scene, 87, 16, '', TextStyle.WINDOW, { fontSize: '72px' });
this.abilityNameText.setOrigin(1, 0);
this.add(this.abilityNameText);
@@ -33,26 +36,32 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
this.shown = false;
}
showAbility(pokemon: Pokemon) {
showAbility(pokemon: Pokemon): void {
this.pokemonNameText.setText(`${pokemon.name}'s`);
this.abilityNameText.setText(pokemon.getAbility().name);
if (this.shown)
return;
if (this.tween)
this.tween.stop();
this.tween = this.scene.tweens.add({
targets: this,
x: 10,
x: shownX,
duration: 500,
ease: 'Sine.easeOut',
onComplete: () => this.tween = null
});
this.setVisible(true);
this.shown = true;
}
hide() {
hide(): void {
if (!this.shown)
return;
if (this.tween)
this.tween.stop();