Rotating ball depending on balls direction

Hey all
I am creating a simple game for my kids where they can shoot away a soccerball and when then have set the force and the direction it shoots the ball and collision and all is working BUT.

I want the ball object to rotate depending on direction so when it hits the ground or flies it must rotate according to its direction.

Any help is highly appreciated [import]uid: 22737 topic_id: 5808 reply_id: 305808[/import]

soccerBall:applyAngularImpulse(angularImpulse)
the impulse can be positive or negative; clockwise and counter-clockwise
[import]uid: 12635 topic_id: 5808 reply_id: 21512[/import]

Do you mind sharing your code to shoot the ball please, I posted a topic on forum on moving an object
but I have not received any reply/help so I been stuck with just reading and trying different method to
make my game work but still no luck :frowning:
What i`m trying to do is when you touch the ball you decide where to shoot it left, right, up, down
(no corner direction) I manage to make it move 1 direction out of the 4 but every time I touch the ball it will
only move to that 1 direction I want the ball to listen to me which out of the 4 direction to be shot at.

Thank You,
[import]uid: 30314 topic_id: 5808 reply_id: 21517[/import]

Hey
Here is the code that I use to shoot the ball if different directions and with different force. But you will find the same code almost in the pool sample app here

[lua]–> aim stuff
target = display.newImage( “gfx/target.png” )
target.x = ball.x; target.y = ball.y; target.alpha = 0

– Shoot the cue ball, using a visible force vector
local function ballShot( event )
local t = target

local phase = event.phase

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

– Stop current cueball motion, if any
–t:setLinearVelocity( 0, 0 )
–t.angularVelocity = 0

target.x = ball.x
target.y = ball.y

startRotation = function()
target.rotation = target.rotation + 4
end

Runtime:addEventListener( “enterFrame”, startRotation )

local showTarget = transition.to( target, { alpha=0.4, xScale=0.4, yScale=0.4, time=200 } )
myLine = nil

elseif t.isFocus then
if “moved” == phase then

if ( myLine ) then
myLine.parent:remove( myLine ) – erase previous line, if any
end
myLine = display.newLine( t.x,t.y, event.x,event.y )
myLine:setColor( 255, 255, 255, 80 )
myLine.width = 8

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

local stopRotation = function()
Runtime:removeEventListener( “enterFrame”, startRotation )

end

local hideTarget = transition.to( target, { alpha=0, xScale=1.0, yScale=1.0, time=200, onComplete=stopRotation } )

if ( myLine ) then
myLine.parent:remove( myLine )
end
physics.start()

– Strike the ball!
ballInMove = true
ball:applyForce( (event.x-t.x)*0.01, (event.y-t.y)*0.01, t.x, t.y)

end
end

– Stop further propagation of touch event
return true
end[/lua] [import]uid: 22737 topic_id: 5808 reply_id: 21550[/import]