Hi Peach,
I have already assign touch listener on the object that is “underneath”. but when object is moving over
underneath object then event is not detecting. I heve not idea conentBounds.
For more information I showing my code below.
[lua] onColission=function(event)
print(event.target.name)
eraseLine()
initializeCirclePos()
end
newLine = function ( event )
local body = event.target
local phase = event.phase
local stage = display.getCurrentStage()
if “began” == phase then
stage:setFocus( body, event.id )
body.isFocus = true
---------writing line----------------
if(tempLine==nil) then
isLine = true
tempLine=display.newLine(event.x, event.y, event.x, event.y)
tempLine:setColor(rcolor, gcolor, bcolor)
tempLine.width=selectedWidth
prevX = event.x
prevY = event.y
end
elseif body.isFocus then
if “moved” == phase then
if body.x > display.contentWidth then
body.x = display.contentWidth - body.width
body.y = display.contentHeight - body.height
elseif body.x < 0 then
body.x = body.width
body.y=body.height
else
body.x = event.x
body.y=event.y
end
---------tracing line-------------------------
if(tempLine==nil) then
isLine = true
tempLine=display.newLine(event.x, event.y, event.x, event.y)
tempLine:setColor(rcolor, gcolor, bcolor)
------tempLine.width=30
tempLine.width=selectedWidth
prevX = event.x
prevY = event.y
end
if isLine == true then
ractgangle_hit[lineIndex] = display.newLine(prevX, prevY, event.x, event.y)
ractgangle_hit[lineIndex]:setColor(rcolor, gcolor, bcolor)
-------ractgangle_hit[lineIndex].width = 30
ractgangle_hit[lineIndex].width = selectedWidth
local i
rc[rcIndex] = display.newCircle(ractgangle_hit[lineIndex].x,ractgangle_hit[lineIndex].y,selectedWidth/2)
rc[rcIndex]:setFillColor(rcolor, gcolor, bcolor);
writeScreen:insert(rc[rcIndex])
rcIndex = rcIndex + 1
ractgangle_hit[lineIndex].objname = “Point”…lineIndex
writeScreen:insert(ractgangle_hit[lineIndex])
–print("No of lines "…lineIndex)
prevX = event.x
prevY = event.y
lineIndex = lineIndex + 1
currLineIndex = currLineIndex + 1
end
circle:toFront()
------removeing draw line when its goes outside of line–
for i=1,#tracecontent[1].dot do
if event.target.x==tracecontent[imageIndex].dotpos[i].x and event.target.y==tracecontent[imageIndex].dotpos[i].y then
print(“STOP DRAWING”)
eraseLine()
initializeCirclePos()
break;
end
end
-------------end----------------------------------
elseif “ended” == phase or “cancelled” == phase then
stage:setFocus( body, nil )
body.isFocus = false
----------tracing line----------------------------
circle:toFront()
end
end
– Stop further propagation of touch event
return true
end
loadTraceLetter = function()
alphabetImage = content[1].image[imageIndex]…“trace.png”
soundIndex=content[1].image[imageIndex]
alphabet = display.newImageRect( alphabetImage, 522, 332)
alphabet.x = centerX
alphabet.y = centerY-30
storeScreenObjs(alphabet)
writeScreen:insert(alphabet)
---------------------loading dot image---------------
for p=1,#tracecontent[imageIndex].dot do
dotImg=display.newImageRect(tracecontent[imageIndex].dot[p]…".png",20,20)
dotImg.name=p
dotImg.x=tracecontent[imageIndex].dotpos[p].x
dotImg.y=tracecontent[imageIndex].dotpos[p].y
storeScreenObjs(dotImg)
writeScreen:insert(dotImg)
dotImg:addEventListener(“touch”, onColission)
end
--------display circle here----------------------
circle = display.newImageRect(“sabir.png”,90,90)
circle.xScale=0.5
circle.yScale=0.5
circle.x=tracecontent[imageIndex].cirPos[1].x
circle.y=tracecontent[imageIndex].cirPos[1].y
storeScreenObjs(circle)
circle:addEventListener( “touch”, newLine )
writeScreen:insert(circle)
return true
end
loadTraceLetter() [/lua] [import]uid: 75428 topic_id: 27957 reply_id: 113197[/import]