Is graphics.newOutline not working anymore?

Hi!

I can’t get graphics.newOutline to work anymore?!? I have used it many times before but now it does not create a body. Anyone else experiencing this?

I get an error message:
ERROR: levels/1.lua:156: physics.addBody() : invalid “outline”

Oh, I guess I have some strange settings in Photoshop because outline works on other images, but not the ones I save in Photoshop.

Anyone knows what might have happened?  :rolleyes:

There are quite many possible answers to that question, so rather than guess, if you would upload zip of the project file that contains the “problem code and image”, we could probably spot the issue pretty fast. Without having access to the image, I’d guess that the file format you saved the image in was wrong or you had some odd alpha channel settings.

It still works for me.

Here is an old answer to an old outline question I investigated:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2016/07/outlineBug.zip

Ignore the code and outline for the right side in the example.  It is not a bug.

If that didn’t help, please make a tiny project with an example of your test and body image.  Then we can give feedback.

My suspicion is:

  • Image may not be correctly sized/dimensioned.
  • Image may not have transparency where needed (alpha low but not 0)
  • Image may be too complex.
  • Image may be locked or in use otherwise.

Again, if not working please attach a tiny example in a zip file we/I can run and you’ll get better input on this one.

Cheers,

Ed

Thanks for great tips. I think my shape might be too complex?!? 
I renewed my PhysicsEditor subscription so now all is good for me, but I still think it is strange.

I would appreciate it if you could try to figure this out. Here is a zip-file:

https://www.dropbox.com/s/0gzq5lrwrnw8q8g/outlineNotWorking.zip?dl=0

You just hit the nail in the head.

You can’t create concave physics shapes directly in Corona (or box2d for that matter). When graphics.newOutline is used on images that are of concave shapes, the engine automatically creates multiple convex bodies and pieces them together. This is simple enough if you are using graphics.newOutline to create a body for basic shapes, like a star, but your shape is really complex. As it is a hollow ring with a segment missing, the engine would have to break it apart into so many tiny convex shapes, that I guess it just gives up.

When you create concave shapes using the physicsEditor, it essentially uses the same trick, i.e. it breaks concave shapes down to several convex shapes.

Oh, that explains it! I did not know that. Getting a little wiser every day.

Nice to know for the next time I’m using outline.

Thanks for the help  :slight_smile:

Exactly. Everything Xedur@Spyric said, plus even ‘codingNinja.png’ wasn’t really working.

It was creating an approximate shape, but the source shape was simply too smooth to fit.

I tweaked your example to show you the issue w/ ‘concave’ shapes.

See ‘mod’ in this zip file: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/10/outlineHelp.zip

While I think the feature is ‘neat’ it is one of the few features I will only use if I test every shape on multiple devices.  I much prefer to define my own exact body shapes.

I think this is mostly suited to simple shapes (low angular complexity and non-concave) where the physics shape does not need to match the visible shape.  i.e. A coin or a gem that needs to be collided with to pick up.

Oh, I guess I have some strange settings in Photoshop because outline works on other images, but not the ones I save in Photoshop.

Anyone knows what might have happened?  :rolleyes:

There are quite many possible answers to that question, so rather than guess, if you would upload zip of the project file that contains the “problem code and image”, we could probably spot the issue pretty fast. Without having access to the image, I’d guess that the file format you saved the image in was wrong or you had some odd alpha channel settings.

It still works for me.

Here is an old answer to an old outline question I investigated:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2016/07/outlineBug.zip

Ignore the code and outline for the right side in the example.  It is not a bug.

If that didn’t help, please make a tiny project with an example of your test and body image.  Then we can give feedback.

My suspicion is:

  • Image may not be correctly sized/dimensioned.
  • Image may not have transparency where needed (alpha low but not 0)
  • Image may be too complex.
  • Image may be locked or in use otherwise.

Again, if not working please attach a tiny example in a zip file we/I can run and you’ll get better input on this one.

Cheers,

Ed

Thanks for great tips. I think my shape might be too complex?!? 
I renewed my PhysicsEditor subscription so now all is good for me, but I still think it is strange.

I would appreciate it if you could try to figure this out. Here is a zip-file:

https://www.dropbox.com/s/0gzq5lrwrnw8q8g/outlineNotWorking.zip?dl=0

You just hit the nail in the head.

You can’t create concave physics shapes directly in Corona (or box2d for that matter). When graphics.newOutline is used on images that are of concave shapes, the engine automatically creates multiple convex bodies and pieces them together. This is simple enough if you are using graphics.newOutline to create a body for basic shapes, like a star, but your shape is really complex. As it is a hollow ring with a segment missing, the engine would have to break it apart into so many tiny convex shapes, that I guess it just gives up.

When you create concave shapes using the physicsEditor, it essentially uses the same trick, i.e. it breaks concave shapes down to several convex shapes.

Oh, that explains it! I did not know that. Getting a little wiser every day.

Nice to know for the next time I’m using outline.

Thanks for the help  :slight_smile:

Exactly. Everything Xedur@Spyric said, plus even ‘codingNinja.png’ wasn’t really working.

It was creating an approximate shape, but the source shape was simply too smooth to fit.

I tweaked your example to show you the issue w/ ‘concave’ shapes.

See ‘mod’ in this zip file: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/10/outlineHelp.zip

While I think the feature is ‘neat’ it is one of the few features I will only use if I test every shape on multiple devices.  I much prefer to define my own exact body shapes.

I think this is mostly suited to simple shapes (low angular complexity and non-concave) where the physics shape does not need to match the visible shape.  i.e. A coin or a gem that needs to be collided with to pick up.