Newer
Older
lostmynuts / shared / js / Engine / Display / DrawableWebGraphic.js
Engine.DrawableWebGraphic = class extends Engine.Drawable
{
    constructor(graphicURL /*string*/)
    {
        if (graphicURL === undefined) graphicURL = "";
        super();

        if (graphicURL != "") { this.loadFromURL(graphicURL); }
    }

    loadFromURL(graphicURL /*string*/)
    {
        this.graphicURL = graphicURL;

        this.loader = new PIXI.Loader();
        this.loader.add(graphicURL, graphicURL);
        this.loader.load((loader, resources) => this.textureLoaded(loader, resources));
    }

    textureLoaded(loader, resources)//texture_id /*int*/, tex /*Texture2D*/)
    {
        if (resources[this.graphicURL] !== undefined)
        {
            this.texture = resources[this.graphicURL].texture;
        }
    }
}