Hi. I made a function, which spawns a ball.
[lua]function spawnBall()
local ball = display.newImage( “ball.png” )
physics.addBody( ball, { density = 1.0, friction = 0.3, bounce = 0.0, radius = 100 } )
physics.setGravity( 0, 10 )
crate.x = math.random(250)
crate.y = -40
end[/lua]
In my project, I want there to be a Button, that spawns the ball. I’ve got this figured out, accept I only want ONE ball to spawn. Is there a way to limit the number of times a function can run? This would help me in many ways.
Here’s the button code:
[lua]local play = display.newImage( “play.png” )
play:scale( .5, .5 )
play:addEventListener( “touch”, spawnBall )[/lua] [import]uid: 25216 topic_id: 11712 reply_id: 311712[/import]
Now I just need to make a function that stops the button.
[import]uid: 25216 topic_id: 11712 reply_id: 42590[/import]