Move circle with touch some element

Hi!
I have some problem, when i move my finger on rectangle my circle dos’t move, i want to circle go with my finger. Now when i touch circle jump to some position:

[code]
_W = display.contentWidth/2
_H = display.contentHeight/2

local physics = require(“physics”)
physics.start()
physics.setGravity( 0, 0 )

local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

display.setStatusBar( display.HiddenStatusBar )

local statek

function scene:createScene( event )
local Gra = self.view

function setPasekRuchu()
local pasek = display.newRect(-150,0, 150,_W*2)
pasek:setFillColor(255,255,255)
Gra:insert(pasek)
pasek:addEventListener( “touch”, ruchStatkiem )
end

function setStatek(x,y)
local sensorRadius = 50
statek = display.newCircle( x, y, sensorRadius )
statek:setFillColor(255,255,255)
Gra:insert(statek)
end
function ruchStatkiem( event )

local t = event.target
local phase = event.phase

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

elseif t.isFocus then

if “moved” == phase then

elseif “ended” == phase or “cancelled” == phase then

display.getCurrentStage():setFocus( nil )
self.isFocus = nil
end

end
return true
end
end

function scene:enterScene( event )
local Gra = self.view
setPasekRuchu()
setStatek(100,100)
end

function scene:exitScene( event )
local Gra = self.view
end
function scene:destroyScene( event )
local Gra = self.view
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
[/code] [import]uid: 117910 topic_id: 35792 reply_id: 335792[/import]

Take a look at this:

http://developer.coronalabs.com/code/copypaste-touch-function

I think your problem is that you don’t have anything in the ‘moved’ phase.

Also, your scoping is wrong. Move the non-local functions out of the createScene function. [import]uid: 8271 topic_id: 35792 reply_id: 142371[/import]

Solution if somebody need:

[code]
local function Rusz( self, event )
if event.phase == “began” then
–transition.to( statek, { time=250, x=100, y= event.y } )
event.target.isFocus = true
elseif event.target.isFocus then

if event.phase == “moved” then
if event.y >=700 then
event.y =700
elseif event.y <= 70 then
event.y = 70
end
transition.to( statek, { time=0, x=100, y= event.y } )
end
return true
end
end
[/code] [import]uid: 117910 topic_id: 35792 reply_id: 142647[/import]

Take a look at this:

http://developer.coronalabs.com/code/copypaste-touch-function

I think your problem is that you don’t have anything in the ‘moved’ phase.

Also, your scoping is wrong. Move the non-local functions out of the createScene function. [import]uid: 8271 topic_id: 35792 reply_id: 142371[/import]

Solution if somebody need:

[code]
local function Rusz( self, event )
if event.phase == “began” then
–transition.to( statek, { time=250, x=100, y= event.y } )
event.target.isFocus = true
elseif event.target.isFocus then

if event.phase == “moved” then
if event.y >=700 then
event.y =700
elseif event.y <= 70 then
event.y = 70
end
transition.to( statek, { time=0, x=100, y= event.y } )
end
return true
end
end
[/code] [import]uid: 117910 topic_id: 35792 reply_id: 142647[/import]