In my game I have an object falling, what I’m looking to do is when you tap object1, five object2’s will spawn from object1. I only know how to spawn objects at a specific point, but since object1 is moving I have no clue how to go about doing this, can anyone help? :}
[code]
function obj1Spawn()
rand = math.random( 90 )
if(rand < 100 ) then
obj1 = display.newImage(“obj1.png”)
obj1.x = math.random(5, 280)
obj1.y = -60
physics.addBody( obj1, {density = 2.0, friction = 1.3})
obj1.myName = “obj1”
obj1.collision = onobj1Collision
obj1:addEventListener(“collision”, obj1 )
end
end
local spawnObj1 = timer.performWithDelay( 5786, obj1Spawn, 100)
function onObj1Collision( self, event )
if (event.phase == “began” ) then
if(self.myName == “obj1”) then
if(event.other.myName == “player”) then
score = score + 10
scoreText.text = tostring(score)
self:removeSelf()
elseif (event.other.myName == “ground”) then
self:removeSelf()
end
end
end
end [import]uid: 114389 topic_id: 22931 reply_id: 322931[/import]