Hi… it’s me again… 
I’m trying to come up with a solution to this:
[lua]-- ball collisions
local function ballCollides( self, event )
if ( event.phase == “ended” ) then
–print( self.name … ": collision ended with " … event.other.name )
if event.other.name == “The Square” then
self.bonus = self.bonus + 1
print("Ball bonus: " … self.bonus)
elseif event.other.name == “The Ground” then
self.bouncesToDisable = self.bouncesToDisable - 1
print("Bounces to disable Ball: " … self.bouncesToDisable)
if self.bouncesToDisable < 0 then
transition.to(self, { time = 500, alpha = 0, onComplete = removeBall})
end
end
end
end
function removeBall(???)
???:removeSelf()
end[/lua]
Basically, it checks the collisions on a ball.
- if it hits the square, a bonus is awarded
- if it hits the ground a few times, there’s an alpha transition, and at the end I wanted it removed.
Problem is, since I’m making the function ready for my tons-o-balls creator, I can’t simply put a “ball:removeSelf()” on my function.
So, how can I pass the “self” value to this new function? I couldn’t find anything in the documentation.
The messy way I’m trying to avoid is creating a FOR testing the alpha of each ball and removing those with alpha=0… But I think there’s a cleaner way of doing it! [import]uid: 11130 topic_id: 3784 reply_id: 303784[/import]