Removing Objects in Groups

How would you remove multiple objects that spawned on a Timer perform Delay. Meaning when there items falling you would that be removed on collision. Again meaning ok you have a bucket and you use that bucket to catch the falling items. When the items are caught they are removed. That what I’m trying to say, of how to remove objects in groups.

Sorry If not to clearly explained [import]uid: 17058 topic_id: 19293 reply_id: 319293[/import]

just remove on collision, its working perfectly fine with physics engine
[lua]local function onCollision(event)
if event.phase == “began” and event.other.name == “fruit” then
display.remove(event.other)
event.other = nil
end
end[/lua] [import]uid: 16142 topic_id: 19293 reply_id: 74409[/import]

@darkconsoles So in that example like the falling fruit will be destroy it will still work even if I add a drag body to the fruit. [import]uid: 17058 topic_id: 19293 reply_id: 74413[/import]

it will remove it all, listeners to it, physics body etc [import]uid: 16142 topic_id: 19293 reply_id: 74416[/import]

@darkconsoles when you did in the line code

event.other.name = "fruit"

how would I name “fruit” to event.other.name [import]uid: 17058 topic_id: 19293 reply_id: 74423[/import]

just write you object this parameter:
[lua]local obj = display.newRect(…)
obj.name == “fruit” – this line[/lua] [import]uid: 16142 topic_id: 19293 reply_id: 74438[/import]

@darkconsoles I tried that already and the items wouldn’t remove [import]uid: 17058 topic_id: 19293 reply_id: 74455[/import]

your “fruit” must be physics body too…
obviously youre doing something wrong it seems
you can hook up with me on skype and we will figure your problem out…
id:superfranky22 [import]uid: 16142 topic_id: 19293 reply_id: 74457[/import]

@darkconsole it already had physics body what I’m trying to do is drag moving balloons to a square that also has physics. So when the ball is drag to square it should be removed but when I do that nothing happens. I’ ll review my code again i’'m not at home so just let me see I’m might find the problem when I get home [import]uid: 17058 topic_id: 19293 reply_id: 74460[/import]

lookie here, few minutes and all done
i hope this is exactly what you need
copy\paste and play
[lua]local physics = require(“physics”)
physics.start()
physics.setGravity(0,5)
local ballGroup = display.newGroup()
local score = 0

local score_txt =display.newText("Score: ",0,0,nil,30)
score_txt.x = 100; score_txt.y = 50
score_txt:setTextColor(255,0,0)
score_txt.text = "Score: "… score

local function spawn_ball()
local ball = display.newCircle(ballGroup,0,0,30)
ball.x = math.random(50,300)
ball.y = -50
physics.addBody(ball, {radius = 30})
ball.name = “ball”
end

timer.performWithDelay(500, spawn_ball, 0)
local basket = display.newRect(0,0,50,70)
basket.x = display.contentWidth/2
basket.y = display.contentHeight - 80
physics.addBody(basket, “static”)

local function drag(event)
if event.phase == “began” then
event.target.isFocus = true
elseif event.phase == “moved” and event.target.isFocus then
event.target.x = event.x
event.target.y = event.y
end
return true
end

basket:addEventListener(“touch”, drag)

local function show_text()
local text = display.newText("+1", 0,0, nil, 30)

score = score + 1
score_txt.text = "Score: "… score
text.alpha = 1
text.x = basket.x
text.y = basket.y - 100
transition.to(text, {time=1000,y = text.y - 50, alpha = 1, onComplete = function() display.remove(text) end})
end

local function onCollision(event)
if event.phase == “began” and event.other.name == “ball” then
display.remove(event.other)
show_text()
end
end

basket:addEventListener(“collision”, onCollision)[/lua] [import]uid: 16142 topic_id: 19293 reply_id: 74539[/import]

yes exactly what I needed thanks [import]uid: 17058 topic_id: 19293 reply_id: 74541[/import]