I intend to have 2 x buttons, which are a left arrow and a right arrow.
When the user touches one of the buttons, the player character,(player1) rotates constantly about it’s centre point. The left button rotates anti-clockwise and the right button clockwise.
The player is a physics body, so using player1.rotation gives unpredictable results.
the following code totates the player by an increment every time the button is pressed, but does not rotate smoothly until the user stops pressing the button.
How can I get the player to rotate smoothly and continuously while the button is pressed?
local leftArrow = display.newRect(0,0,20,20)
leftArrow.x = \_W / 8
leftArrow.y = \_H / \_H + \_H / 10
leftArrow:setFillColor(0,255,0)
leftArrow.alpha = .75
local function lrot(event)
player1:rotate ( player1.rotation -10 )
end
leftArrow:addEventListener ("touch", lrot)
Thanks in advance. [import]uid: 67933 topic_id: 14162 reply_id: 314162[/import]