Hey guys how do I make it so on button press a certain object will move toward a certain angle.I have it set up so when the right button is pressed it rotates 90 degrees same for left accept negative 90 but when I rotate left then try to rotate right it only rotates 90 degrees like I told it but how do I make its so it rotates to the right side when the right btn is pressed and same for left.
Thanks Tyler J
rotatedright=false rotatedleft = false local bg = display.newImage("background.jpg",200,200,500,500) bg:scale(2.3,2.5) local sidebar= display.newRect(400,100,50,50) local tank = display.newImage("tank.png",50,50) tank:scale(0.25,0.25) local leftbtn = display.newImage("btn.png",50,300) local rightbtn = display.newImage("btn.png",100,300) -- Called when the scene's view does not exist local function moveright( event ) print("buttonR was pressed") tank.x = tank.x+10 if rotatedright == false then tank:rotate( 90 ) rotatedright = true end end local function moveleft( event ) print("buttonL was pressed") tank.x = tank.x-10 if rotatedleft == false then tank:rotate( -90 ) rotatedleft = true end end leftbtn:addEventListener("touch",moveleft) rightbtn:addEventListener("touch",moveright)