Here is the function I am trying to use to restart the level.
[blockcode]
function changeScene(e)
if (e.phase == “ended”) then
play_again.isVisible = false
play_again.alpha = 0
back_to_menu.isVisible = false
play_again.alpha = 0
if(e.target.scene) then
– Load main menu
director:changeScene(e.target.scene);
else
– Load game again
SCORE_LRG = 20
SCORE_MED = 15
SCORE_SML = 10
_score = 0
HEALTH_LRG = 7
HEALTH_MED = 2
HEALTH_SML = 5
_health = 100
health_up = false
end
end
end
play_again:addEventListener(“touch”, changeScene);
back_to_menu:addEventListener(“touch”, changeScene);
[/blockcode]
And here is the function that drops my objects randomly
[blockcode]
function newBlock()
rand = math.random( 100 )
if (rand < 60) then
local smallblock = display.newImageRect(“images/s_boulder.png”, 21, 21);
smallblock.x = 60 + math.random( 160 )
smallblock.y = -100
physics.addBody(smallblock, {density = 0.3, friction = 0.3})
smallblock:setLinearVelocity(0,300)
smallblock.name = “small block”
smallblock:addEventListener(“touch”, removeSmall)
localGroup:insert(smallblock)
elseif (rand < 80) then
local mediumblock = display.newImageRect(“images/m_boulder.png”, 27, 25);
mediumblock.x = 60 + math.random( 160 )
mediumblock.y = -100
physics.addBody(mediumblock, {density = 1.0, friction = 0.3})
mediumblock:setLinearVelocity(0,1)
mediumblock.name = “medium block”
mediumblock:addEventListener(“touch”, removeMedium)
localGroup:insert(mediumblock)
else
local largeblock = display.newImageRect(“images/l_boulder.png”, 42, 41);
largeblock.x = 60 + math.random( 160 )
largeblock.y = -100
physics.addBody(largeblock, {density = 2.0, friction = 0.3, radius = 20.5})
largeblock:setLinearVelocity(0,1)
largeblock.name = “large block”
largeblock:addEventListener(“touch”, removeLarge)
localGroup:insert(largeblock)
end
end
local dropBlocks = timer.performWithDelay( 500, newBlock, 100 )
[/blockcode] [import]uid: 47722 topic_id: 12015 reply_id: 43894[/import]