Skip to content

Commit

Permalink
⚡ Allow Background class to accept a pixi.js texture
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Feb 15, 2021
1 parent 3ffef58 commit b67429f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/data/ct.release/backgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class Background extends PIXI.TilingSprite {
constructor(texName, frame = 0, depth = 0, exts = {}) {
var width = ct.camera.width,
height = ct.camera.height;
const texture = ct.res.getTexture(texName, frame || 0);
const texture = texName instanceof PIXI.Texture ?
texName :
ct.res.getTexture(texName, frame || 0);
if (exts.repeat === 'no-repeat' || exts.repeat === 'repeat-x') {
height = texture.height * (exts.scaleY || 1);
}
Expand Down
3 changes: 2 additions & 1 deletion src/typedefs/ct.js/Background.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface IBackgroundTemplate {

declare class Background extends PIXI.TilingSprite {
constructor(bgName: string, frame: number, depth: number, exts: object);
constructor(pixiTexture: PIXI.Texture, frame: number, depth: number, exts: object);
depth: number;
shiftX: number;
shiftY: number;
Expand All @@ -14,4 +15,4 @@ declare class Background extends PIXI.TilingSprite {
scaleX: number;
scaleY: number;
repeat: string;
}
}

0 comments on commit b67429f

Please sign in to comment.