Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Is graphics.newOutline not working anymore?
Started by sirmania Oct 03 2018 01:01 AM

8 replies to this topic
outline physics graphics error body

Best Answer XeduR @Spyric , 04 October 2018 - 02:25 AM

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.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 150 posts
  • Corona SDK

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"



[TOPIC: post.html]
#2

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 150 posts
  • Corona SDK

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:



[TOPIC: post.html]
#3

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 361 posts
  • Corona SDK

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.



[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,363 posts
  • Corona SDK

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.



[TOPIC: post.html]
#5

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,363 posts
  • Corona SDK

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



[TOPIC: post.html]
#6

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 150 posts
  • Corona SDK

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



[TOPIC: post.html]
#7

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 361 posts
  • Corona SDK

  Best Answer

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.


  • sirmania likes this

[TOPIC: post.html]
#8

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 150 posts
  • Corona SDK

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  :)



[TOPIC: post.html]
#9

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,363 posts
  • Corona SDK

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.


Edited by roaminggamer, 04 October 2018 - 08:23 AM.

  • sirmania likes this


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: outline, physics, graphics, error, body