[lua]local w = display.contentWidth
local player = display.newRect ( 160, 360, 160, 10 )
local leftbtn = display.newRect ( w * 0.15, h * 0.9, 60, 40 )
leftbtn:setFillColor ( 0, 1, 0 )
local rightbtn = display.newRect ( w * 0.85, h * 0.9, 60, 40 )
rightbtn:setFillColor ( 0, 0, 1 )
function playerrotationleft ( event )
if event.phase == “began” then
player.rotation = player.rotation - 15
end
end
function playerrotationright ( event )
if event.phase == “began” then
player.rotation = player.rotation + 15
end
end
leftbtn:addEventListener ( “touch”, playerrotationleft )
rightbtn:addEventListener ( “touch” , playerrotationright)[/lua]
what i want to do here is, when i keep touching the leftbtn or rightbtn I want the bar to keep rotating
but when i set event.phase == “began” it active once
if i delete the event.phase == “began” it active twice
or event.phase == “moved” it active when i move in the btn
my question is what should i do to make the bar keep rotating if i keep “pressing” the btn