Detecting collision and separating?

Hello

I am working on a game app, and have come across a snag.

The platforms that i have spawning spawn “inside” one another.

This is not what i had intended.

I do not want to add all of my code unless i need too.

local pnorm = display.newImage("platform\_normal2.png"); pnorm.x = display.contentCenterX + math.random(-110, 110) pnorm.y = 615 pnorm.xScale = 1 pnorm.yScale = 1 physics.addBody( pnorm, "dynamic", { density=1, friction=0, bounce=0} ) pnorm.gravityScale = gravity pnorm:applyForce(0, -1, pnorm.x, pnorm.y) pnorm.isFixedRotation = true pnorm.myName = "Normal Platform"

there are multiple types of platforms, each of which have their own characteristics.

This code is from the Normal ones.

They spawn “off screen” in random packs of 1-3 with random characteristics.

I’m wanting to add something to auto adjust their spawning, so that they are directly left.right of one another.(if they spawn inside eachother)

At times they will spawn, fairly spread out.

Other times, they are severely clumped up.

I tried to use a filter, but that didn’t look to good.

best way i can think to show you what i am talking about is an image.

http://imgur.com/WWRdoSV

Thanks for any advice!

I’ve been working on this issue for quite awhile, and cannot come up with a solution.

Let me know if more info is needed!

a shot in the dark here ok?

set this in your code: 

physics.setDrawMode( "hybrid" )

And see how the physics bodies is applied to your images… Maybe the body is not covering the whole image.

hmm.  No the bodies cover the images completely.
The borders are also the border of the images.

Let me rephrase and ask this.

If one platform collides with another.  How can i code them to move apart?

Platform A touched Platoform B

So A Moves .x -10?

Thats what i am looking for.  I do not know how to whitelist a collision for an operation though.

I wouldn’t want the same thing to happen to my player when it lands on a platform.

Usually when they collide they will move apart without any intervention of code… like physics in real world. (At least is what happen in my codes, i just specify the physics bodies for the objects and the collision will happen like real physics) 

Unless you want the platform to go specifically to the point x = x - 10.  If you do, then you got to control that in the collision listener. Is that what you want? Or just let them collide and separate to points that is not you who specify?

Which kind of physics bodies are you using for the others platforms, “dynamic” too?

If you could post more code, like your collision listener…

a shot in the dark here ok?

set this in your code: 

physics.setDrawMode( "hybrid" )

And see how the physics bodies is applied to your images… Maybe the body is not covering the whole image.

hmm.  No the bodies cover the images completely.
The borders are also the border of the images.

Let me rephrase and ask this.

If one platform collides with another.  How can i code them to move apart?

Platform A touched Platoform B

So A Moves .x -10?

Thats what i am looking for.  I do not know how to whitelist a collision for an operation though.

I wouldn’t want the same thing to happen to my player when it lands on a platform.

Usually when they collide they will move apart without any intervention of code… like physics in real world. (At least is what happen in my codes, i just specify the physics bodies for the objects and the collision will happen like real physics) 

Unless you want the platform to go specifically to the point x = x - 10.  If you do, then you got to control that in the collision listener. Is that what you want? Or just let them collide and separate to points that is not you who specify?

Which kind of physics bodies are you using for the others platforms, “dynamic” too?

If you could post more code, like your collision listener…