Thank you for your suggestions Lococo, the flag works.
jpot328,
this is what I did.
this works for my game, but i’m sure it will give you an idea.
[lua]-- flag
local ballinAir = false
local removeTouch = false
local resetTouch = false
– assume ball exist already…
local ballCollision = function (self, event)
if event.phase == “began” then
if event.other.objectName == “ground” then
self:removeSelf() – remove the ball
self = nil
ballinAir = false – the ball collides with another object so no longer in the air
resetTouch = true
end
end
end
firebutton.collision = lunchballTouch – assumming i have a firebutton setup already
firebutton:addEventListener(“touch”, lunchballTouch)
local lunchballTouch = function (event)
if event.phase == “ended” then
spawnball() – this is assuming i have the spawnball function already in my code somewhere
removeTouch = true
ballinAir = true – this tells me that the ball is flying through the air
end
end
local whateverEnterFrame = function ()
if (removeTouch) then
firebutton:removeEventListener(“touch”, lunchballTouch)
end
if (resetTouch) and not (ballinAir) then
firebutton:addEventListener(“touch”, lunchballTouch)
end
end
Runtime:addEventListener(“enterFrame”, whateverEnterFrame)
[import]uid: 12455 topic_id: 6066 reply_id: 20928[/import]