Hi i’m making a simple game and i need help
i want to make each object of the group draggable and not the group himself
local function onRectangletouch(e)
local t = e.target
if ( e.phase == “began” ) then
t.startMoveX = t.x
t.startMoveY = t.y
elseif (e.phase == “moved”) then
t.x = (e.x - e.xStart) + t.startMoveX
t.y = (e.y - e.yStart) + t.startMoveY
end
return true
end
local function rect_words(tab_img) —tab_img contain {a,b,c,d,e,f,g,h,i,a}
local rect = {}
local pos = 1
local j
local char_rand
local char_group = display.newGroup( )
for i = 1, #tab_img do
if (#tab_img ~= 0) then
rect[i] = display.newRoundedRect(char_group, (pos * 120) - 60, halfH + halfH/2, 100, 100, 3)
rect[i]:setFillColor(0, 0, 0, 0)
rect[i]:setStrokeColor(0, 0, 1)
rect[i].strokeWidth = 5
j = mRand(#tab_img)
char_rand = display.newText(char_group, tab_img[j], rect[i].x, rect[i].y, fawnfont, 50)
tab_img = del_elem_in_tab(tab_img, j)
physics.addBody( rect[i], “static”)
rect[i].name = i
pos = pos + 1
end
char_group:addEventListener( “touch”, onRectangletouch )
end
end
I only want to move one by one and it move the whole group i don’t know how to do can someone help me please
thx