show body parts previews
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user