I need help with this collision function within my game. For some reason, the terminal says that the “removeSelf” method is nil, but I checked the physics engine and it removes the display object even though it displays these errors. How can I stop these errors from occuring?
local function onCollision( self, event )
print( event.other.myName )
if ( event.other.myName == "first bound" ) then
fadeout = transition.to( self, { alpha="0", xScale="0.01", yScale="0.01", time=100 } )
local function closure()
transition.cancel(fadeout)
self.isBodyActive = false
self:removeSelf()
end
timer.performWithDelay(150, closure, 1)
print("removed")
elseif ( event.other.myName == "second bound" ) then
local function closure()
transition.cancel(fadeout)
self.isBodyActive = false
self:removeSelf()
end
timer.performWithDelay(150, closure, 1)
print("removed")
elseif ( event.other.myName == "third bound" ) then
print( self.myName )
print( "allow thru" )
elseif ( event.other.myName == "fourth bound" ) then
print( self.myName )
print( "allow thru" )
elseif ( event.other.myName == nil ) then
print("nil")
else
print("not reconizable collision")
print( event.other )
end
end
Thank you for your help in advance [import]uid: 29220 topic_id: 8539 reply_id: 308539[/import]
