Hi
Here is my first simple test in lua/corona. My problem is that the blue square is always behind the yellow square. How can I bring the blue square to the foreground when I drag it?
[lua]local square1 = display.newRect( 20, 20, 100, 100 )
square1:setFillColor(0, 200, 255)
local square2 = display.newRect( 220, 380, 100, 100 )
square2:setFillColor(230, 230, 0)
function dragSquare1 (event)
if event.phase == “began” then
square2:removeEventListener(“touch”, dragSquare2)
end
if event.phase == “moved” then
square1.y = event.y
square1.x = event.x
end
if event.phase == “ended” then
square2:addEventListener(“touch”, dragSquare2)
end
end
function dragSquare2 (event)
if event.phase == “began” then
square1:removeEventListener(“touch”, dragSquare1)
end
if event.phase == “moved” then
square2.y = event.y
square2.x = event.x
end
if event.phase == “ended” then
square1:addEventListener(“touch”, dragSquare1)
end
end
square1:addEventListener(“touch”, dragSquare1)
square2:addEventListener(“touch”, dragSquare2)[/lua] [import]uid: 10820 topic_id: 3245 reply_id: 303245[/import]
[import]uid: 10820 topic_id: 3245 reply_id: 9664[/import]