William McCarty
William McCarty

Reputation: 839

removing Objects from an event in Corona SDK

So I'm creating a game where an enemy is firing a bullet. The bullet eventrully hits a collision I made, when it hits the end of the screen. Im wanting at this point to remove it and clear the address back to a nil value. When checking the address before and after the collision, no change was made. please help with any insight you might have on this.

local onCollision = function(event)
        if event.phase == "began" then
            event.object2:removeSelf();
            event.object2 = nil;
        end
end
Runtime:addEventListener("collision",onCollision);

Upvotes: 0

Views: 1101

Answers (1)

vovahost
vovahost

Reputation: 36007

local onCollision = function(event)
        if event.phase == "began" then
            event.target:removeSelf();
            event.target= nil;
        end
end
Runtime:addEventListener("collision",onCollision);

Upvotes: 1

Related Questions