Sign in to follow this  
GBear

PIXI.Text looks not efficient

Recommended Posts

Hi. everyone..

i wanna talk about PIXI.Text.

PIXI.Text is very useful to create game or something..

but it seem not to consider memory

   first. it create canvas every time when PIXI.Text created

   second. PIXI.Text call updateTexture when set text like  'power.text = "super power"';

 

is there some problems if canvas has only one..?

 

thx..

Share this post


Link to post
Share on other sites

I think you are misunderstanding the PIXI.Text object.

 

It sure creates a canvas when you create a new object, which makes sense, since you are creating a new Texture.

When you update the text then it just sets a dirty flag. And in the next rendering loop, it redraws the text once.

 

All optimization lies in your responsibility.

 

For instance, when you re-use some text te.g. you have a user list and next to every user name is a "Add as Friend" text, you could do something like:

var addAsFriend = new PIXI.Text("Add as Friend");

var button1 = new PIXI.Sprite(addAsFriend.texture);

var button2 = new PIXI.Sprite(addAsFriend.texture);

var button3 = new PIXI.Sprite(addAsFriend.texture);

...

 

You could as well take that texture and use it as a baseTexture and divide it into multiple frames.

var manyTexts = new PIXI.Text("Add as Friend\nRemove Friend\nIgnore");

and then just set a frame per line.

 

It sure is not meant to constantly change huge texts.

But do you really need to do that? What are you using it for?

 

If you are worried about the amount of textures/canvas, you could always use a Bitmap text or write a shader to act like a Bitmap text.

 

 

Share this post


Link to post
Share on other sites

@SebastianNette hi good to see you...~~

thx. first.. 

when i create pixi.text very time created canvas. is it right?

and if change text like text.text = 'aaaa',  it called updateTexture  it seems like recreate basetexture.

if everytimes basetexture recreated when update texture by 'dirty', so   All PIXI.Text looks to need only one canvas to create TEXT

..

Quote

If you are worried about the amount of textures/canvas, you could always use a Bitmap text or write a shader to act like a Bitmap text.

my game is mmorpg so a lot of text is drawn like attribute to chatting message,  quest text, game text......., 

so i will create a lot of PIXI.TEXT... and sometimes PIXI.TEXT create realtime 

 

how can i control pixi.text in this case..?

 

 

ps> do you have plat to update PIXI.INPUT more good on ios or android with new PIXI? ^^/

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.