Hello fellow Corona Developers,
I have been having some troubles with object removal through group. All I am trying to accomplish is to remove a group, and shortly after repopulate the same group with newer objects.
and here go() function is as follows:
local go = function(total, grupo)
local temp = math.random(1, #imagesTable)
randYVal = \_H\*0.5+310
randXVal = \_W\*0.5
for i = 1, total do
local spawns = spawn(
{
image = imagesTable[temp],
objTable = spawnTable,
density = 0.026,
hasBody = true,
friction = 1.0,
bounce = 0.2,
radius = 23,
bodyType = "dynamic",
x = math.random(43, \_W\*0.5),
y = math.random( -\_H\*0.5 + 264 , -\_H\*0.5 + 276 ),
group = grupo or heartGroup,
}
)
--add eventListener to all of the spawned objects
spawns:addEventListener("touch", onTouch)
spawns:addEventListener("collision", onCollision)
end
end
Here’s my short code snippet where I am trying to clean the heartGroup by using jonathan Beebes at al cleangroup.lua and then repopulate it immediately.
I am able to clean the group - remove all objects, but then when go(0) [/code] is called, which it’s intent is to put a new set of objects on screen, nothing happens.
Clearly it’s cleaning all the object, even the new ones, just spawned. I have tried to increment the timer to a higher value in hopes that it wouldn’t clean the new objects, but no luck.
Any help will be highly appreciated.
Thank you in advance. <br> <br>.<br>.<br>.<br> if ( wave_counter == 1) then<br> <br> cleanGroup( heartGroup) <br> heartGroup = nil <br> <br> goTimer = timer.performWithDelay(1945, go(0), 0)<br><br> [import]uid: 75258 topic_id: 26979 reply_id: 326979[/import]