我有这个 onCollision 功能,但每次游戏重新开始时,碰撞都会加倍
local function onCollision(event)
if event.phase == "began" and gameIsActive == true then
local obj1 = event.object1;
local obj2 = event.object2;
if obj1.name == "jetplayer" and obj2.name == "BCloud1" then
MinLife()
elseif obj1.name == "jetplayer" and obj2.name == "BCloud2" then
pontsMin10()
elseif obj1.name == "jetplayer" and obj2.name == "BCloud3" then
pontsMin20()
elseif obj1.name == "jetplayer" and obj2.name == "GCloud1" then
pontsplus50()
elseif obj1.name == "jetplayer" and obj2.name == "bla" then
score = score - 20
end
end
end
Runtime:addEventListener( "collision", onCollision )
function scene:exitScene( event )
Runtime:removeEventListener( "collision", onCollision )
有什么理由发生这种情况吗?