Renderer
Renderer

Reputation: 51

PIXIJS transition from one application to another

I can't understand in any way.
I need my old application to be cleared.
That is, when I clicked and followed the ajax, some textures that have the same name remain the previous ones, as well as all the properties and others from the previous loading.

    if (Object.keys(loader.resources).length) {
//            for (var texture in PIXI.utils.TextureCache) {
//                var tmp = PIXI.Texture.removeFromCache(texture);
//                tmp.destroy(true);
//            }
//            for (var texture in PIXI.utils.BaseTextureCache) {
//                PIXI.utils.BaseTextureCache[texture].destroy(true);
//            }
            PIXI.utils.BaseTextureCache = PIXI.utils.TextureCache = loader.resources = {};
        loader.reset();
        app.destroy({
            children: true,
            texture: true,
            baseTexture: true
        });
    }

Will it be possible to complete the ajax transition application in order to launch a new one with new textures of the same name?

In the download, I tried to add "?Number" to the image address:

let add = function (arr) {
    while (!loader.loading) {
        for (var i in arr) {
            loader.add(i, arr[i] + '?' + new Date().getTime());
        }
        break;
    }
};

But still nothing comes out.

I make the transition through:

$.get(href, function (data) {
    //code
});

Everything loads and works fine, except for the pictures. They hang, and after the transitions, they do not change, but only everything mixes and sometimes we observe it from the previous ones.

Of course, after reloading the page at the current address, everything works as it should, it doesn’t work only on ajax, for some reason the cache is not discarded.

Upvotes: 0

Views: 373

Answers (1)

Renderer
Renderer

Reputation: 51

The issue is resolved, everything works, I just forgot to update the variable with resources.

Due to the fact that at the first initialization:

let resource = PIXI.loader.resources;

Which I had in the global area. Due to the fact that I did not update it, I could not change the textures.

Now, after all the removal and new filling, I substitute again:

resource = PIXI.loader.resources;

And everything began to work as it should.

Upvotes: 1

Related Questions