[FIXED] How can I use graphics.newOutline() with @2x and @4x image substitution?

Hi Kerem,

I recently created a simple “shape flipper” function, which could potentially be used to flip the coordinates of newOutline()-generated shapes. Do you want me to post it here? It only works for horizontal (y-axis) flipping, not vertical, but in truth a vertical flip is the same as a 180-degree-rotated horizontal flip.

Brent

Hi Brent, thanks for offering that. Indeed would love to have a copy. Maybe a post in Code Exchange for maximum exposure? Thanks in advance. 

Albert, I tried 2174 and I can see graphics.newOutline is doing something different @2x and @4x so thank you very much for your prompt response. There is a problem though and it is not returning the right outline as 1x did against the 1x image. It might be something to do with my images which was not becoming a problem earlier. May I send you 3 images for you to see for yourself?

Nevermind. graphics.newOutline is working very well. The issue was with my image such that higher resolution version had some very fine gaps / breaks in the outline. These must be compressed when I downshifted the image to 1x so outline for 1x was tracing well. Once I went to 4x suddenly my trace was broken but this has nothing to do with the graphics.newOutline api. All is good. Case closed. 

Hi Kerem,

I just posted my “physics body flipper” in the Code Exchange. Please test it out and let me know if there are any issues.

Currently, it only handles horizontal flipping. Adding vertical flipping would probably be easy enough, but I don’t have time to tinker with that and test it. As I said above, you can always take the “easy way out” and just rotate the horizontally-flipped body 180 degrees and achieve the same thing. :slight_smile:

http://code.coronalabs.com/code/physics-body-shape-flipper

Brent

Hi Brent, 

Will test as soon as possible. Thank you very much for sharing this solution. I agree, rotate + flip horizontal will cover all possible needs. 

Regards,

Kerem

I noticed the following in my console while running my app in simulator at 4x res… 

The generation of the physics body for this outline had to be cut short. Please provide a simpler input.

The resulting physics body still looked and worked ok so I don’t know what was cut short but then I reduced the coarsenessInTexels value one at a time from the initial 2 and eventually found a number which still looked and worked great did not generate this error. Thought I should share with others reading this thread about newOutline API and high-res images …