【发布时间】:2015-07-26 05:20:49
【问题描述】:
我正在制作游戏,但我遇到了问题,当角色跳到一个物体上时,会发生一系列事件。但是,因为它与对象多次碰撞,事件发生多次,这是我不想要的。我想要的是在角色跳到对象上并停留在对象顶部之后事件发生一次。那么,当角色跳到另一个物体上时,让事件再次发生一次......等等。
这是我的相关代码的一部分:
function playerCollision( self, event )
--if hit bottom column, u get points
if event.target.type == "player" and event.other.type == "startColumn2" then
if event.phase == "began" then
print ("collided")
addColumns()
timer.performWithDelay(5000, addBody)
startColumn2: translate(-4, 0)
startcolumn2hit = true
end
end
if event.target.type == "player" and event.other.type == "bottomColumn" then
print ("hit column")
onPlatform = true
end
end
我将如何做到以防止多次碰撞?
【问题讨论】: