custom background for slots

This commit is contained in:
Piotr 'pwh' Hanusiak
2022-03-30 13:02:02 +02:00
parent 4c93060f85
commit d0ad5f8299
6 changed files with 52 additions and 67 deletions
@@ -32,6 +32,30 @@ export class TexturesHelper {
}
}
public static createFloorRectangleTexture(
scene: Phaser.Scene,
newTextureKey: string,
width: number,
height: number,
sourceTextureKey: string,
sourceTextureFrame?: number | string,
sourceTextureWidth: number = 32,
sourceTextureHeight: number = 32
): void {
const rt = scene.make.renderTexture({ x: 0, y: 0, width, height }, false);
const widthTiles = Math.ceil(width / sourceTextureWidth);
const heightTiles = Math.ceil(height / sourceTextureHeight);
for (let x = 0; x < widthTiles; x += 1) {
for (let y = 0; y < heightTiles; y += 1) {
rt.drawFrame(sourceTextureKey, sourceTextureFrame, x * 32, y * 32);
}
}
rt.saveTexture(newTextureKey);
rt.destroy();
}
public static createRectangleTexture(
scene: Phaser.Scene,
textureKey: string,