I have a function that shoots bullets
--shoot bullets
local shootBullets = function(event)
local bullet = display.newImage("bullet.png")
bullet.x = 0
bullet.y = display.contentCenterY
physics.addBody( bullet, { density=3.0, friction=0.5, bounce=0.05 } )
bullet.isBullet = true
bullet.rotation = false
bullet:setLinearVelocity( event.x, event.y-180 )
print(event.y)
end
When you click on the sky background
sky:addEventListener( "touch", shootBullets )
This would be cool if I needed repetitive shooting like a galaga game. However, I just want to shoot one bullet on press and as soon as it shots it. You have to let go and touch again to shoot it. Any help on this logic is appreciated.
Lua noob.
[import]uid: 6500 topic_id: 9823 reply_id: 309823[/import]