show body parts previews

This commit is contained in:
Piotr 'pwh' Hanusiak
2022-03-17 11:03:04 +01:00
parent a22504b354
commit 7703a76689
6 changed files with 119 additions and 394 deletions
@@ -37,15 +37,13 @@ export class WokaBodyPartSlot extends GridItem {
.rectangle(0, 0, this.SIZE, this.SIZE, this.config.color)
.setStrokeStyle(this.config.borderThickness, this.config.borderColor);
this.bodyImage = this.scene.add.image(
offsetX,
offsetY,
config.bodyImageKey ?? `body${Math.floor(Math.random() * 33) + 1}`
);
this.bodyImage = this.scene.add
.image(offsetX, offsetY, config.bodyImageKey ?? "")
.setVisible(config.imageKey !== undefined);
this.image = this.scene.add
.image(offsetX, offsetY, config.imageKey ?? "")
.setVisible(config.imageKey !== undefined);
.setVisible(config.bodyImageKey !== undefined);
this.setSize(this.SIZE + this.config.borderThickness, this.SIZE + this.config.borderThickness);
@@ -59,14 +57,22 @@ export class WokaBodyPartSlot extends GridItem {
this.scene.add.existing(this);
}
public setBodyTexture(textureKey: string, frame?: string | number): void {
this.bodyImage.setTexture(textureKey, frame);
public setTextures(bodyTextureKey?: string, imageTextureKey?: string): void {
this.setBodyTexture(bodyTextureKey);
this.setImageTexture(imageTextureKey);
}
public setBodyTexture(textureKey?: string, frame?: string | number): void {
this.bodyImage.setVisible(textureKey !== undefined && textureKey !== "");
if (textureKey) {
this.bodyImage.setTexture(textureKey, frame);
}
}
public setImageTexture(textureKey?: string, frame?: string | number): void {
this.image.setVisible(textureKey !== undefined || textureKey !== "");
this.image.setVisible(textureKey !== undefined && textureKey !== "");
if (textureKey) {
this.bodyImage.setTexture(textureKey, frame);
this.image.setTexture(textureKey, frame);
}
}