Is there a way to flip a GraphicList?


(Sharon Shalom Iluz) #1

Is there a way to flip a GraphicList?

i have 2 images in this graphic and there are not at zero zero both images are at different position

and i would like to flip them as a hole image is that possible ?


(Justin Wolf) #2

Unfortunately, there’s no “quick” method to flipping all of the children of a Graphiclist. I imagine the reason behind this is because some Graphics do not have the flipped property (Stamp for example). Here’s one way you should be able to go about flipping all of your Graphiclist's children:

for each (var g:* in myGraphiclist.children)
{
	if (g.hasOwnProperty("flipped")) g.flipped = true;
}

If you’re finding that you may need to use this more than once, consider adding the following setter to your Graphiclist.as (found in net.flashpunk.graphics).

        /**
	 * Flips all of the Graphiclist's children, if possible.
	 */
	public function set flipped(b:Boolean):void
	{
		for each (var g:* in _graphics)
		{
			if (g.hasOwnProperty("flipped")) g.flipped = b;
		}
	}

And then simply calling myGraphiclist.flipped = true; should do it!


(Sharon Shalom Iluz) #3

thank it works but now i got performance issues :stuck_out_tongue:


(Justin Wolf) #4

How often are you calling the function? It shouldn’t be too bad so long as you’re not calling it every frame of an update loop. And flipping graphics doesn’t add to any performance woes as far as I know.