--The Code function addStar(\_x,\_y) local star = display.newImage("star2.png") star.x = \_x; star.y = \_y; star.collType = "passthru" function star:preCollision( event ) event.contact.isEnabled = false end function star:collision(event) if event.contact then event.contact.isEnabled = false; local collideObject = event.other if ( event.phase == "began" ) then event.contact.isEnabled = false; event.contact.isEnabled = false; elseif ( event.phase == "ended" ) then event.contact.isEnabled = false; if(collideObject.collType == "landed\_safely") then -- the collType of the a "safely landed" animal hitting the star, other animals are ignored event.contact.isEnabled = false; --self:fadeOut() timer.performWithDelay(5000, self:removeSelf()); updateScore({star = self}); end print( "ended.") end end end star:addEventListener("collision") star:addEventListener("preCollision") --starDanceA() starGroup:insert(star); physics.addBody(star, "static"); end addStar(325, 200); addStar(225, 275); addStar(425, 275)
Ultimately, I want the stars to be static and to have collision detection, but I don’t want anything to actually bounce off of them. Is there a way to code this using the physics engine that works 100% of the time (my code only works sometimes) without having to code the collision detection “by hand”?