Last active
May 28, 2019 21:16
-
-
Save sajmoni/300d65e73ff8cc658ffdfb257b0722aa to your computer and use it in GitHub Desktop.
Revisions
-
sajmoni revised this gist
May 28, 2019 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,4 +13,9 @@ export default app => (filename) => { if (!texture) throw new Error(`Texture "${filename}" not found.`); return texture[1]; }; // Example usage, assuming you have an image called 'player': // const texture = getTexture(‘player’) // const sprite = new Pixi.Sprite(texture) -
sajmoni created this gist
May 28, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ // "app" is an instance of PixiJS Application export default app => (filename) => { const { resources, } = app.loader; const texture = Object .values(resources) .filter(resource => resource.textures) .flatMap(resource => Object.entries(resource.textures)) .find(([key]) => key === `${filename}.png`); if (!texture) throw new Error(`Texture "${filename}" not found.`); return texture[1]; };