调换水龙头的位置-电晕SDK

倾角

如何查看两个水龙头并转换两个水龙头以彼此交换位置?例如:我点击对象[1],然后点击对象[2],然后它们将过渡并交换位置。你们将如何尝试进行此设置?

干杯

麦孔·费尔德豪斯

像这样的东西:

local last = nil

local circle1 = display.newCircle(display.contentCenterX - 50, display.contentCenterY - 50, 25)
circle1.fill = { 0.0, 0.6, 1.0 }
local circle2 = display.newCircle(display.contentCenterX + 50, display.contentCenterY + 100, 25)
circle2.fill = { 1.0, 0.5, 0.0 }
local circle3 = display.newCircle(display.contentCenterX + 75, display.contentCenterY - 100, 25)
circle3.fill = { 0.4, 0.5, 0.0 }

local function onTouch( event )
    local target = event.target
    if event.phase == "ended" then
        if last == nil then
            last = target
        elseif last ~= target then
            transition.moveTo( last, { x=target.x, y=target.y } )
            transition.moveTo( target, { x=last.x, y=last.y } )
            last = nil
        end
    end
end

circle1:addEventListener( "touch", onTouch )
circle2:addEventListener( "touch", onTouch )
circle3:addEventListener( "touch", onTouch )

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章