graphics.newOutline() oddities and tips

I’ve been playing with graphics.newOutline() quite a bit recently, and have found some oddities and tips I figured I’d pass along:

I found that unless I use an image that is completely white, the outline that is produced is unpredictable. If I use a non-white image, I sometimes get an outline that is the bounding box of the entire image, or sometimes an outline that is just a small square. The documentation says the newOutline() works by detecting non-transparent alpha pixels, but I’ve found that the image needs to be pure white on an alpha background. Even the orange star image in the original tutorial doesn’t work for me. It’s probably not a coincidence that the star image used in the samples directory is pure white.

The larger the image I use for the outline, the more unpredictable the results. Sometimes I get holes in the outline. A trick I found is to use a smaller image for the outline, while using the full-size image for the actual display object. For instance, if the image for my display object is 512x256, then I will create a pure-white version of my image at 128x64, and use this white, smaller image to generate the outline. Then, I simply iterate through the vertices in the outline and multiply every coordinate by 4 before I turn my display object into a physics body with the outline.

hi poon,

thanks for the heads up about odd shapes with the graphics.newOutline() API.though about that part where u multiply the coordinates by 4,how do u do it?

mind showing some code?

Thanks

Thanks, that’s good investigating.

I’ve also noticed that if you use an outline generated using newOutline() as a physics outline on anything other than an image the physics body is disastrously skewed/broken. (Bug submitted.)

It’s even worse if you try to fill a polygon with an image (does work) and scale or offset the filling image (definitely does not work!)

hi poon,

thanks for the heads up about odd shapes with the graphics.newOutline() API.though about that part where u multiply the coordinates by 4,how do u do it?

mind showing some code?

Thanks

Thanks, that’s good investigating.

I’ve also noticed that if you use an outline generated using newOutline() as a physics outline on anything other than an image the physics body is disastrously skewed/broken. (Bug submitted.)

It’s even worse if you try to fill a polygon with an image (does work) and scale or offset the filling image (definitely does not work!)