Rotate object by multi-touch

Hi All,

Working on my first “game” here… I have a bar (stick) on the screen, and I want to be able to rotate this bar by touching and draggin.
If not possible by multi-touch (with to fingers - one finger on each end of the bar…)
Then just rotate by touching one of the ends of the bar.
Any tips on how that can be possible?

This is what I have:
local physics = require(“physics”)
physics.start()
physics.setGravity (0,-20)
local ui = require( “ui” )
– some other code…

local bar = display.newImage( “board.png”, true )
game:insert( bar )
bar.x = 160
bar.y = 150
physics.addBody( bar, “static”, { friction=0.5, bounce=0.3 } )

I also have this piece of code for dragging:

local function startDrag( event )
local t = event.target

local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true

– Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y

– Make body type temporarily “kinematic” (to avoid gravitional forces)
event.target.bodyType = “kinematic”

– Stop current motion, if any
event.target:setLinearVelocity( 0, 0 )
event.target.angularVelocity = 0

elseif t.isFocus then
if “moved” == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0

elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false

– Switch body type back to “dynamic”, unless we’ve marked this sprite as a platform
if ( not event.target.isPlatform ) then
event.target.bodyType = “dynamic”
end

end
end

– Stop further propagation of touch event!
return true
end
bar:addEventListener( “touch”, startDrag )

Any help on the rotation will be much appreciated!
Best regards,

Michael
Denmark
[import]uid: 12916 topic_id: 4723 reply_id: 304723[/import]