How to use this touch function for more than one object?

Hello,

I am loading more than one image on the screen and added this touch function that roaminggamer posted. It works but when I have two images loaded both move at the same time when I move either of them. Can anyone tell me what I need to change so only one image moves at a time?

Thanks!!

Warren

-- touch listener function function touch( self, event ) if event.phase == "began" then self.markX = self.x -- store x location of object self.markY = self.y -- store y location of object elseif event.phase == "moved" then local x = (event.x - event.xStart) + self.markX local y = (event.y - event.yStart) + self.markY self.x, self.y = x, y -- move object based on calculations above end return true end local function LoadLabel( event ) CT1 = 0 local labelno2 = composer.getVariable( "labelno" ) for row in db:nrows("SELECT filename, width2, height2, posx, posy FROM text WHERE labelno = '" .. labelno2 .. "'") do local fn2 = row.filename local w2 = 0 w2 = row.width2 local height2 = row.height2 CT1 = CT1 + 1 imgText[CT1] = display.newImageRect( fn2, system.TemporaryDirectory, w2, height2 ) imgText[CT1].anchorX = 0 imgText[CT1].anchorY = 0 imgText[CT1].x = row.posx imgText[CT1].y = row.posy imgText[CT1].id = fn2 imgText[CT1].touch = touch Runtime:addEventListener( "touch", imgText[CT1] ) end end

Actually I just noticed I can touch anywhere in the screen to move the objects. Maybe I need to find different code then. I only added the touch events to those images being loaded.

I got it. I used the example DragMe from the sample code.

Thanks!

Actually I just noticed I can touch anywhere in the screen to move the objects. Maybe I need to find different code then. I only added the touch events to those images being loaded.

I got it. I used the example DragMe from the sample code.

Thanks!