在 Corona SDK 中,如何防止玩家一直被困在平台里?

我正在尝试制作一个小型无尽奔跑游戏,在这个游戏中,一个玩家(一个小盒子)在平台之间左右移动。我注意到玩家被困在了平台里。我尝试调整玩家物理体和平台物理体的密度,但都没有起作用。这和 anchorX,anchorY 有关吗?

enter image description here

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)
点赞
用户2305605
用户2305605

尝试将一个形状添加到物理体。

Corona - Physics - Add Body

另外,像Piglet以上提到的那样,将物理绘制模式设置为Hybrid,在调试中非常有用。

2016-05-03 01:51:39