Hi there guys, im making a game where i need to drag and drop display objects. My problem is that when i drag the object, i need to know a parameter of this object.
i got this code…
-- make 'myObject' listen for touch events myObject[i]:addEventListener( "touch", touch ) myObject has the parameter id, cat and e. When its dragged, i need to know cat value. function touch( event ) print("---------") if event.phase == "began" then markX = event.target.x -- store x location of object markY = event.target.y -- store y location of object elseif event.phase == "moved" then local x = (event.x - event.xStart) + markX local y = (event.y - event.yStart) + markY event.target.x, event.target.y = x, y -- move object based on calculations above end cat2=event.target.cat return true end
i read that event.target is null if this was called by a runtime touch event, but then, how can i resolve my problem?
Thanks,
Kinari