Physics body for ground does not line up to the image on iPad devices

The physics body for my ground is slightly higher than the image of the ground itself. Please note that this only occurs on iPad devices. How can I change this in a manner that it won’t affect the other sizes?

local groundShape = { -halfW \* 1.4, ground.height \* 0.32, halfW \* 1.4, ground.height \* 0.32, halfW \* 1.4, ground.height \* 0.52, -halfW \* 1.4, ground.height \* 0.52} physics.addBody( ground, "static", { friction=1, bounce = 0, shape=groundShape }) --This code creates the ground's physics body, halfW is display.contentCenterX

The attached screenshot shows what it looks like for the iPad device.

Thank you.

Does this have something to do with my config.lua file?

Also, the declaration for the halfW variable is here:

local screenW, screenH, halfW = display.actualContentWidth, display.actualContentHeight, display.contentCenterX

I wouldn’t use those type of calculations for the ground. Is the ground simply a rectangle? If so, why not just let the physics default trace the bounds of the image?

If it’s a rectangle but you need to reduce it to slightly smaller than the actual image bounds, you can use an “offset rectangular body” as described here:

https://docs.coronalabs.com/api/library/physics/addBody.html#offsetangled-rectangular-body

Brent

Thanks Brent, but the image of the ground is actually a lot larger than it seems. I will try to crop it and see what happens.

I have found what is causing the problem the dimensions to the @2x image is not proportionate to the dimensions of the normal sized images.

Fixing the proportions worked.

Does this have something to do with my config.lua file?

Also, the declaration for the halfW variable is here:

local screenW, screenH, halfW = display.actualContentWidth, display.actualContentHeight, display.contentCenterX

I wouldn’t use those type of calculations for the ground. Is the ground simply a rectangle? If so, why not just let the physics default trace the bounds of the image?

If it’s a rectangle but you need to reduce it to slightly smaller than the actual image bounds, you can use an “offset rectangular body” as described here:

https://docs.coronalabs.com/api/library/physics/addBody.html#offsetangled-rectangular-body

Brent

Thanks Brent, but the image of the ground is actually a lot larger than it seems. I will try to crop it and see what happens.

I have found what is causing the problem the dimensions to the @2x image is not proportionate to the dimensions of the normal sized images.

Fixing the proportions worked.