Rob says that you can either rotate it anti-clockwise by using - 90 and clockwise by using + 90, not to write the both code at the same time
You can write anything in transition.to command . like + 90 or + 100 or + 140… It depends on you !!
This should be your code
display.setStatusBar (display.HiddenStatusBar) centerX = display.contentCenterX centerY = display.contentCenterY local box = display.newImageRect("crate.png" , 160 , 160) box.x=centerX box.y=320 box.rotation=90 local function rotateBox (event) if (event.phase=="began") then box.rotation = box.rotation - 90 -- to rotate it anti clockwise without any transition end end Runtime:addEventListener("touch" ,rotateBox)
Or
display.setStatusBar (display.HiddenStatusBar) centerX = display.contentCenterX centerY = display.contentCenterY local box = display.newImageRect("crate.png" , 160 , 160) box.x=centerX box.y=320 box.rotation=90 local function rotateBox (event) if (event.phase=="began") then box.rotation = box.rotation + 90 -- to rotate it clockwise end end Runtime:addEventListener("touch" ,rotateBox)
Or
display.setStatusBar (display.HiddenStatusBar) centerX = display.contentCenterX centerY = display.contentCenterY local box = display.newImageRect("crate.png" , 160 , 160) box.x=centerX box.y=320 box.rotation=90 local function rotateBox (event) if (event.phase=="began") then transition.to(box , {time = 500 , rotation = -90 , delta = true}) -- to rotate it anticlockwise with a transition end end Runtime:addEventListener("touch" ,rotateBox)