Hi!
I’m stuck with this and can’t find any solution so hoping someone can help me…
I’m using the code from the Simple Pool demo with an elastic line to aim and shoot an object in a certain direction. I would like the orientation of that object to stay always aiming at the target. Right now with the code below it flips side depending where I aim, up or down, passing a certain value. “redBug” is the object that I want to rotate correctly…
[lua]
if ( myLine ) then
myLine.parent:remove( myLine )
end
myLine = display.newLine( t.x, t.y, event.x, event.y )
myLine:setColor( 255, 10, 10, 150 )
myLine.width = 8
local xDist = t.x - event.x ; local yDist = t.y - event.y
local angleRot = math.deg( math.atan( yDist/xDist ) )
redBug.rotation = angleRot [/lua]
Thanks a lot for any help
[import]uid: 10517 topic_id: 8505 reply_id: 308505[/import]