These are chat archives for pixijs/pixi.js

22nd
Jul 2017
Jeff Lung YK
@jefflung
Jul 22 2017 03:46
Hi anyone know GSAP work with Pixi here?
spacejack
@spacejack
Jul 22 2017 19:31
Would this be the correct way to allocate texture & sprite resources, use them, then dispose of them when done?
// Assume we already have a stage and loaded an img: HTMLImageElement

let tex = PIXI.Texture.from(img)
let sprites = []

for (let i = 0; i < 3; ++i) {
    const s = new PIXI.Sprite(tex)
    sprites.push(s)
    stage.addChild(s)
}

// .. animate sprites etc ..

// Now dispose...

for (let i = 0; i < 3; ++i) {
    stage.removeChild(sprites[i])
}

// Let GC handle the sprites (Or must we use sprite.destroy()?)
sprites = []

// Explicitly free the texture
tex.destroy()
tex = undefined

// GC handles the img
img = undefined

// (keep stage because app is still using it)