Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

Corona crashes when creating physical body with polygon outline from a display group.
Started by victor.aladjov Jan 03 2020 07:33 AM

1 reply to this topic
physics outline displaygroup crash
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 1 posts
  • Corona SDK

Hi. I'm having a problem with defining the outline for a physics object in the game  I'm developing. I use the graphics.newOutline method to get the coordinates from a  specific image. Then I create a group in which I insert a an image. Lastly I create a  physical body based on that group with an outline from the specific image (and I need  to add other images to the group later). If I create the physical body directly from  an image, the outline is appied without a problem. However, when I try creating the  physical object from a group, Corona Simulator crashes. Here is the sample code from  the function I use to create the physical body:
local targetGroup = display.newGroup()
local target = display.newImageRect( "GFX/image.png", 400, 400 )
local targetOutline = graphics.newOutline( 2, "GFX/image.png" )
targetGroup.x, targetGroup.y = display.contentCenterX, display.contentCenterY
physics.addBody( targetGroup, { outline=targetOutline, density=100, friction=0.3,  bounce=0.1 } )

If instead of creating the body with targetGroup I create it with target the whole thing works.

Apologies if the question has already been asked and thank you in advance!


[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Contributor

  • 812 posts
  • Corona SDK

My guess would be that graphics pairs the outline with the image so trying to swap the image for a group during physics.addBody causes the physics engine to crash and take down the simulator. 


If you want to define a group as a physics body I think you will have to define the vertices manually or use physics editor or a similar tool


Also tagged with one or more of these keywords: physics, outline, displaygroup, crash