【发布时间】:2014-04-10 03:03:22
【问题描述】:
我正在和一个收集东西的人一起做游戏,比如硬币。我想检测这两者之间的碰撞,所以我可以取出硬币,但我不希望硬币与角色互动,因为现在它正在稍微减慢他的速度。尽管如此,它仍应在碰撞前与地面相互作用。感谢您的帮助!
function createCoin()
for i = 1, 10 do
coin = display.newCircle(0, 0, 16)
coin.x = totallength - 1000 + i * 100
coin.y = totalheight - 200
physics.addBody(coin,
{bounce = 0, friction = 1, density = 0}
)
game:insert(coin)
coin.myName = "coin"
end
end
createCoin()
local function onCollision(event)
if event.phase == "began" then
if (event.object1.myName == "coin" and
event.object2.myName == "wheel") then
event.object1:removeSelf();
end
end
end
【问题讨论】:
-
能否请您澄清您的问题?减速是主要问题吗?它由
friction参数调节。您可以使用event.contact.friction更改定义两个对象之间摩擦的行为。参考:Coronda SDK blog,Corona docs。据我所知,这就是用于预碰撞处理的方法。