I’m trying to make a small endless running game in which a player (a small box, basically) moves left and right in between platforms. I noticed that the player is dug into the platforms. I tried tweaking the density on both player physics body and platform physics body. But none of them worked. Is this related to anchorX,anchorY by any chance?
=================================================================================
Code
=================================================================================
local physics = require(‘physics’)
physics.start()
player = display.newImageRect(‘boxy.png’,30,30)
player.anchorX = 0
player.anchorY = 0
player.x = 200
physics.addBody(player,‘dynamic’, {density = 1, friction = 0, bounce = 0})
platformLeft = display.newRect(100,300,450,30)
platformLeft:setFillColor(0,0,0)
platformLeft.anchorX = 1
platformLeft.anchorY = 0.5
platformLeft.x = (width - 1) * 30
platformLeft.y = _H + 90
physics.addBody(platformLeft,‘static’, {density = 1, friction = 0, bounce = 0})
platgroup:insert(platformLeft)
platformRight = display.newRect(100,350,450,30)
platformRight:setFillColor(0,0,0)
platformRight.anchorX = 0
platformRight.anchorY = 0.5
platformRight.x = width * 30
platformRight.y = _H + 90
physics.addBody(platformRight,‘static’, {density = 1,friction = 0, bounce = 0})
platgroup:insert(platformRight)