Corona SDK - Square Collision Only?

Below is a sample code of 2 “newCircle” objects, right/left walls and a floor. The reason a floor was added is because I thought maybe if the larger circle was “static” it would behave as a square. From what I can tell, round objects don’t really work in Corona for collission. Everything acts as squares.

Can someone confirm this, or tell me how to fix this so that the small circle interacts with the large circle as real physics would define it.


physics = require(“physics”)
physics.start()
local leftWall = display.newRect (20, 1, 1, display.contentHeight)
local rightWall = display.newRect (display.contentWidth-20, 1, 1, display.contentHeight)
local floor = display.newRect (0, display.contentHeight, display.contentWidth, 1)

physics.addBody (leftWall, “static”, {bounce = 1, density=1, friction = 20})
physics.addBody (rightWall, “static”, {bounce = 1, friction = 20})
physics.addBody (floor, “static”, {bounce = 0.08, friction = 10, filter=floorFilter})
local mySquareCircle = display.newCircle( 400, 500, 300 )
mySquareCircle.strokeWidth = 3
mySquareCircle:setFillColor(140, 140, 140)
mySquareCircle:setStrokeColor(180, 180, 180)
display.setStatusBar( display.HiddenStatusBar )

local myCircle = display.newCircle( 100, 100, 30 )
myCircle:setFillColor(128,128,128)

physics.addBody( mySquareCircle, “dynamic”, { friction=0.5, bounce=0.3 } )

physics.addBody( myCircle, “dynamic”, { density = 1.0, friction = 0.3, bounce = 0.2, radius = 25 } )

myCircle:applyForce(50)
[import]uid: 32936 topic_id: 6125 reply_id: 306125[/import]

I don’t understand the question?
What’s the problem?

Or what do you want to achieve? [import]uid: 10657 topic_id: 6125 reply_id: 20991[/import]

You have to set the physics body to be a circle. And yes, it is stated in the documentation. [import]uid: 5712 topic_id: 6125 reply_id: 20999[/import]

he’s already doing that with one of his objects (it has radius), so i’m a bit lost! [import]uid: 6645 topic_id: 6125 reply_id: 21017[/import]

Hello again.

The goal of the above example is to reproduce the result of 2 round objects (circles). The desired effect is what you would see if you take 2 round objects and roll them around on each other.

In the example above, there’s an invisible area (square) around the larger circle.

It almost feels like there is no circular / curved collision available.

I’m just trying to confirm if that’s true or false, and if it is false, then how do I tell the larger round object that it is a circle, not a square, and ignore the invisible areas around the circle, and allow objects to fall through those parts down to the actual object itself.

Thanks for your reply! [import]uid: 32936 topic_id: 6125 reply_id: 21026[/import]

If my last comment was confusing, open the example for yourself in the Android Simulator for Corona. You will see the small circle drop down onto the larger one, on an area that is invisible. I want it to drop down to the circle itself, and go through the invisible parts of the object.

Thanks! [import]uid: 32936 topic_id: 6125 reply_id: 21027[/import]

thats because you didnt add a radius to the physics properties of the larger one [import]uid: 6645 topic_id: 6125 reply_id: 21031[/import]

Good one. Thanks for the answer :slight_smile: [import]uid: 32936 topic_id: 6125 reply_id: 21060[/import]

in case anyone stumbles onto this and wonders the same thing, i added a radius to the physics body:

physics.addBody( mySquareCircle, “kinematic”, { friction=0.5, bounce=0.3, radius = 300 } )

Thanks again! [import]uid: 32936 topic_id: 6125 reply_id: 21061[/import]

like you already did for myCircle :stuck_out_tongue: [import]uid: 6645 topic_id: 6125 reply_id: 21062[/import]

Haha that’s why I was lost!

Cool! [import]uid: 10657 topic_id: 6125 reply_id: 21112[/import]