Jump to content

Any sources for performance tips?


trsh
 Share

Recommended Posts

I have googled a lot and haven't really found any good materials on tips how to improve render performance, or have to not screw it up. Please share if u know. 1 question from my side:

Is there any point to free movie clips, sprites and them textures when they are not needed? Like the character goes behind the scene. Will that freeing not result in a LAG? If yes, what's the best approach?

Link to comment
Share on other sites

Make sure to call .destroy() on the object you are done with, and to cleanup textures you no longer need call .destroy(true) on them as well.

Hi, does that mean to effectively destroy a sprite I should:

this.removeChild(someSprite);someSprite.destroy();

If I call destroy() on a Container does it also 'destroy' it's children?

Are the textures the sprite is using also destroyed?

Link to comment
Share on other sites

Ok, first, mainly GPU memory is used only for textures. If you are using loader or Sprite.fromImage() then don do anything - textures are cached, and they'll be re-used.

 

That code will upload only ONE texture to GPU: 

var spr1= Sprite.fromImage("my.png")var spr2= Sprite.fromImage("my.png")var spr3= Sprite.fromImage("my.png")var spr4= Sprite.fromImage("my.png")var spr5= Sprite.fromImage("my.png")var spr6= Sprite.fromImage("my.png")

But if you creating many dynamic textures (PIXI.Text for example), destroy() them after use.

 

renderable=false tells pixi to not call renderWebGL(), while visible=false also stops updateTransform() and that means getBounds() wont return you correct result.

Link to comment
Share on other sites

Ok, first, mainly GPU memory is used only for textures. If you are using loader or Sprite.fromImage() then don do anything - textures are cached, and they'll be re-used.

 

That code will upload only ONE texture to GPU: 

var spr1= Sprite.fromImage("my.png")var spr2= Sprite.fromImage("my.png")var spr3= Sprite.fromImage("my.png")var spr4= Sprite.fromImage("my.png")var spr5= Sprite.fromImage("my.png")var spr6= Sprite.fromImage("my.png")

But if you creating many dynamic textures (PIXI.Text for example), destroy() them after use.

 

renderable=false tells pixi to not call renderWebGL(), while visible=false also stops updateTransform() and that means getBounds() wont return you correct result.

 

Yeah, but imagine I have a kind of intro in my game (sprite animations - MovieClip). When that ends, those animations will no longer be needed in the level. Is in not wise then to clear them totaly from memory, to free space for later added ones?

Link to comment
Share on other sites

If you dont need that thing anymore, then destroy its texture.

 

There's another option - destroy() your renderer and re-create it, that will remove every texture from GPU. That's what I use between levels sometimes.

 

Thanks for the tip!

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