i have a main character that i want to
rotate and face the location that i
touch, however the results i am getting are really weird
please help
Here is the code
[lua]local physics = require(“physics”)
local gameUI = require(“gameUI”)
physics.start()
physics.setGravity( 0, 0 )
firefighter = display.newImage( “fireman.png”,400,720)
physics.addBody( firefighter, { density = 200000,friction=0, bounce=0,radius=25} )
function rotatingTheFirefighter(event)
a=firefighter.y-event.y
b=event.x-firefighter.x
goalRotation= math.deg(math.atan(a/b))
if event.phase==“began” then
transition.to(firefighter, { time=15, rotation = goalRotation })
elseif event.phase==“moved” then
transition.to(firefighter, { time=15, rotation = goalRotation })
end
end
Runtime:addEventListener(“touch”, rotatingTheFirefighter)
[/lua] [import]uid: 28068 topic_id: 7478 reply_id: 307478[/import]