Last active
April 25, 2017 17:15
-
-
Save Makio64/d8b2a8350d936681b8ccb6886f4cdd22 to your computer and use it in GitHub Desktop.
PIXI 4.4.x Tips performance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Global : | |
- Dont use PIXI.Graphics | |
- render elements in the order of atlas/textures used : for 2 atlas or texture A & B, then render elements using AAAABBB instead of ABABABA | |
- On branch next from Pixi there is PIXI.mesh.Geometry & shaders very good for perf | |
http://dev.goodboydigital.com/client/goodboy/geometry/examples/index.html#/mesh/uniforms.js | |
- prefer generateSprite to cacheasbitmap to cache container/no animated element | |
Spritesheets: | |
- Use spritesheets whenever its possible | |
- Scales them down to 50% on mobile/tablet | |
- Add the extention @0.5x.png to the 50% scaledown so pixijs will double them automaticaly | |
Texture : | |
- Release memory with : texture.destroy() | |
- If you plan to destroyed more than one at once add a random delay to their destruction to remove freezing | |
- delayed texture destroy if you plan to delete a lot of texture : | |
let t = this.texture | |
setTimeout(t.destroy()},Math.random()*300+100) | |
this.texture = null | |
Text : | |
- Dont change it on everyframe | |
- Double the font size & scale it down to 50% for shape render | |
Mask : | |
- Just dont fucking use it ( except extrem case ) ^_^ | |
- generateSprite if static mask | |
Filters : | |
- Release memory : displayObject.filters = null | |
- If you know the size of them: displayObject.filterArea = new PIXI.Rectangle(x,y,w,h) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment