I’m trying to figure out how to keep the game from crashing if a collision occurs between multiple targets. This is from the the Ghosts vs Monsters code:
local onMonsterPostCollision = function( self, event )
if event.force \> 1.5 and self.isHit == false then
audio.play( monsterPoofSound )
self.isHit = true
print( "Monster destroyed! Force: " .. event.force )
self.isVisible = false
self.isBodyActive = false
-- Poof code below --
if poofTween then transition.cancel( poofTween ); end
greenPoof.x = self.x; greenPoof.y = self.y
greenPoof.alpha = 0
greenPoof.isVisible = true
local fadePoof = function()
transition.to( greenPoof, { time=500, alpha=0 } )
end
poofTween = transition.to( greenPoof, { time=50, alpha=1.0, onComplete=fadePoof } )
monsterCount = monsterCount - 1
if monsterCount \< 0 then monsterCount = 0; end
self.parent:remove( self )
self = nil
local newScore = gameScore + mCeil(5000 \* event.force)
setScore( newScore )
end
end
How would you make ‘self’ recognize two separate objects so that they would both be destroyed? [import]uid: 14032 topic_id: 8994 reply_id: 308994[/import]
[import]uid: 14032 topic_id: 8994 reply_id: 35409[/import]