Hi, I’m trying to create a game where when an object collides with the other type of object in the game a new body of the first object gets created.
I’ll paste the code so that hopefully you can understand better.
function onCollision(self,event)
if event.phase==“began” then
if event.other.name == “cell” then
local newVirus = display.newImageRect(“virus.png”, 90,90)
physics.addBody( newVirus, { density=1, friction=0.5, bounce=0.5, radius=25 })
end
end
endvirus.collision = onCollision
virus:addEventListener(onCollision,virus)
Basically there is a virus and there are several cells. When a virus hits a cell a new virus with the same properties of the original one should be created.
This code is not working, what am I doing wrong?