These are chat archives for pixijs/pixi.js

3rd
Nov 2016
JR Heard
@jrheard
Nov 03 2016 00:43
i think i'm going to change things such that i have one root container (the "stage"), and it has a ton of children, each of which is a Graphics that contains a single rectangle, and since Graphicses are Containers, i can just manipulate each Graphics' .position.x and .position.y whenever i want to move it around. if this is the wrong approach, please let me know! :)
Chad Engler
@englercj
Nov 03 2016 14:50
Note that things you draw within a single Graphics object are batched, but multiple graphics objects are not batched together
JR Heard
@jrheard
Nov 03 2016 14:51
yeah - i'd like to only use one graphics object so i get batching! but i can't figure out how to reliably move around simple rectangles that have been drawn by a graphics object
is that possible?
Chad Engler
@englercj
Nov 03 2016 14:52
Not trivially
JR Heard
@jrheard
Nov 03 2016 14:52
dang
Chad Engler
@englercj
Nov 03 2016 14:52
are the rectangles uniform?
JR Heard
@jrheard
Nov 03 2016 14:53
not sure what you mean by that - they're often but not always squares, and some of the squares are bigger than other ones, so i'm betting the answer is no
Chad Engler
@englercj
Nov 03 2016 14:53
because you can draw one, generate a texture, then create a bunch of sprites (one-per-rect)
JR Heard
@jrheard
Nov 03 2016 14:53
oh, interesting
Chad Engler
@englercj
Nov 03 2016 14:53
if the sprites share a texture they will be batched
JR Heard
@jrheard
Nov 03 2016 14:53
where should i look to learn how to generate a texture based on a rectangle?
JR Heard
@jrheard
Nov 03 2016 14:54
thanks a ton chad, i really appreciate it!
Chad Engler
@englercj
Nov 03 2016 14:54
np
if you have many different shapes you can draw them to a canvas, use the canvas as a texture "spritesheet" and then make all the sprites you need
and since they all share 1 base texture (the canvas) it will batch
JR Heard
@jrheard
Nov 03 2016 14:55
ha, clever! i'll give that a shot!