Jump to content

PIXI.Text looks not efficient


GBear
 Share

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..

Link to comment
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.

 

 

Link to comment
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? ^^/

 

 

 

 

 

 

 

 

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...