Yeah I know that! I got it working using the “Simple Pool” example thats included
It’s shoots perfectly just like I want. Ok lets change the subject a little…
Everything is in a “game”-group used for moving the camera. But this is the problem:
myLine = display.newLine( t.x,t.y, event.x,event.y )
game:insert(myLine)
It’s acting really weird, it’s not following the touch. I’ve think after reading around the forum it’s the group thats messing up the coordinates. How can I fix this?
Like this:
[code]-- Shoot the cue ball, using a visible force vector
local function cueShot( event )
local t = event.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 = t.x
target.y = t.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 )
game:insert(myLine)
myLine:setColor( 255, 255, 255, 100 )
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
– Strike the ball!
boulder.bodyType = “dynamic”
t:applyForce( (t.x - event.x), (t.y - event.y), t.x, t.y )
end
end
– Stop further propagation of touch event
return true
end
boulder:addEventListener( “touch”, cueShot )
[/code] [import]uid: 10657 topic_id: 3277 reply_id: 9807[/import]