Hi guys
Is there any way to respawn an object after removing it?
I’m using the code of a scrolling background, and here is what I have so far.
local object1 = display.newImage("object1.png")
object1.x = object1.contentWidth - 100
object1.y = object1.y - 30
physics.addBody(object1, "kinematic")
local tSpeed = 0.1
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time
local yOffset = ( tSpeed \* tDelta )
object1.y = object1.y + yOffset
if (object1.y + object1.contentHeight) \> 1200 then
object1:translate(0, - 480 \* 2)
end
end
Runtime:addEventListener( "enterFrame", move );
local function onCollision( self, event )
if ( event.phase == "began" ) then
object1:removeSelf(object1)
end
end
object1.collision = onCollision
object1:addEventListener( "collision", object1 )
Once the object has collided & removed, I’d like it to respawn on the next loop.
Anyone able to help with this please?
Thanks in advance! [import]uid: 40538 topic_id: 9544 reply_id: 309544[/import]
[import]uid: 12455 topic_id: 9544 reply_id: 34866[/import]