Jump to content

Pixi.Text() only as Texture-provider?


Jörg Plewe
 Share

Recommended Posts

Hi all!

I have to deal with lots of non-changing text objects. My idea is to use Pixi.Text as a provider for a texture and create a Pixi.Sprite from it. Like so:

const txt = new Text(text, style);
txt.updateText(false);
container.addChild(new Sprite(txt.texture));

This actually works but leaves me with dangling Pixi.Text objects, each allocating a canvas and such, eating up memory.

So I added a destroy():

const txt = new Text(text, style);
txt.updateText(false);
container.addChild(new Sprite(txt.texture));
txt.destroy({texture: false});

which gives me a 

WebGL: INVALID_VALUE: texImage2D: no canvas

Next, I tried to clone the texture before destroying the Pixi.Text:

const txt = new Text(text, style);
txt.updateText(false);
const texture = txt.texture.clone();
container.addChild(new Sprite(txt.texture));
txt.destroy();

which gives me just empty images.

So ... why doesn't the texture cloning work? Are there better ways to deal with that? 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...