Hey guys,
I’ve got this problem I know why it’s happening but can’t find a way to fix it.
I have non- physics collision event with star and player and when player collides with star it should play a sound effect but only once but I get like repeat effect. Here’s my code
----- --Star 2 ------- local function hasMollided(star2, billy) if star1 == nil then return false end if billy == nil then return false end local left2 = star1.contentBounds.xMin \<= billy.contentBounds.xMin and star1.contentBounds.xMax \>= billy.contentBounds.xMin local right2 = star1.contentBounds.xMin \>= billy.contentBounds.xMin and star1.contentBounds.xMin \<= billy.contentBounds.xMax local up2 = star1.contentBounds.yMin \<= billy.contentBounds.yMin and star1.contentBounds.yMax \>= billy.contentBounds.yMin local down2 = star1.contentBounds.yMin \>= billy.contentBounds.yMin and star1.contentBounds.yMin \<= billy.contentBounds.yMax return (left2 or right2) and (up2 or down2) end function testMollisions2() if hasMollided(star1, billy) then myTable.lv1star2 = true star1.isVisible = false if ( myTable.mute ) == false then audio.play(starSound) -- I need this to play only once end end end
If anyone can help it would be great. I’m few days from publishing the game on market and need to fix this asap. Thanks!