tips4design Posted August 21, 2015 Share Posted August 21, 2015 I noticed that when you use groups the group layer size is as large as the longest distance horizontally and vertically between the sprites it contains, even though the sprites are off-screen. Groups are actually DisplayObjectContainers, so that means their canvas (I guess) is going to be that large, even though sometimes it can be much smaller (never larger than the screen). Also, does using groups mean that the sprites are drawn twice? (first on the group and then the group canvas on the world) If this is the case, then if you have multiple nested groups then the sprite will be re-drawn a multiple times (even though none of the container groups alter it's position, scale or anything like that). So, is this how groups work? Does using groups affect performance by using multiple large-size textures? (eg. you have a pixel at 0.0 and one pixel at 1600.1600 and add them in a group, now instead of drawing two pixels you will draw a group of size 1600x1600) Link to comment Share on other sites More sharing options...
rich Posted August 21, 2015 Share Posted August 21, 2015 Groups don't have a canvas of their own. They are just logical containers of sprites. So no, nothing is drawn twice, and no it doesn't create large textures because they don't have textures. Tilde and tips4design 2 Link to comment Share on other sites More sharing options...
wayfinder Posted August 21, 2015 Share Posted August 21, 2015 ...unless you use cacheAsBitmap, right? Link to comment Share on other sites More sharing options...
rich Posted August 21, 2015 Share Posted August 21, 2015 Even then it oy does in canvas mode. In webgl it creates a render texture, not a canvas. Link to comment Share on other sites More sharing options...
netcell Posted August 23, 2015 Share Posted August 23, 2015 If I add a sprite to another sprite, would the caching canvas of the parent draws both of them or only the parent? I mean like if I have a 32x32 sprite at (world) (0,0) added to a 32x32 sprite at (world) (game.width,game.height), how big will the canvas be? Link to comment Share on other sites More sharing options...
rich Posted August 23, 2015 Share Posted August 23, 2015 The canvas is only ever the size you specify in the game constructor. Groups, Sprites, etc do not have their own canvas elements by default. Only if you call cacheAsBitmap on them will it do that, and even then only in Canvas mode. In WebGL it sets up a sprite batch instead. Link to comment Share on other sites More sharing options...
Recommended Posts