Distortion doesn't change touch-area of object

Hey guys

While playing around with the path-attribute of an object I realized that it doesn’t update the touchable area.

It would be nice if the touchable area would adapt to the changes.

I’m still having some crashes and random bugs (Rectangles not appearing or appearing in diffrent colors randomly) while playing around with the corners of an object.

Chris

Do you have code that we can use to reproduce?

Sure:

[lua]

–local trans = require(“trans”)

display.setDefault( “v1Compatibility”, false )

display.setStatusBar( display.HiddenStatusBar )

local centerX,centerY = display.contentCenterX,display.contentCenterY

local rect = display.newRect(0,0,200,200)

rect.anchorX,rect.anchorY = 0.5,.5

rect.x,rect.y = centerX,centerY

rect.rPath = rect.path

rect:setFillColor(0,.5,1)

local corner = {}

corner.tlX = rect.path[‘x1’]

corner.trX = rect.path[‘x3’]

corner.blX = rect.path[‘x2’]

corner.brX = rect.path[‘x4’]

corner.tlY = rect.path[‘y1’]

corner.trY = rect.path[‘y3’]

corner.blY = rect.path[‘y2’]

corner.brY = rect.path[‘y4’]

local debug  = display.newText(“Debug”, 20, 55, native.systemFont, 32)

debug:setTextColor(255,0,0)

debug.x,debug.y = centerX,50

local debugTxt = “”

local function transBack(obj,xx2,yy2)

    transition.to(obj,{time=500,x2=xx2,y2=yy2,transition=easing.outBounce})

end

local function dragRect(event)

    local t = event.target

    local phase = event.phase

    if phase == “began” then

        display.getCurrentStage():setFocus( t, event.id )

        t.isFocus = true

    elseif t.isFocus then

        if phase == “moved” then

            t.x0 = event.x - t.x

            t.y0 = event.y - t.y

            t.path.x2 = corner.blX + t.x0 + t.width/2

            t.path.y2 = corner.blY + t.y0 - t.height/2

            --[[

            t.path.x3 = corner.blX + t.x0 - t.width/2

            t.path.y3 = corner.blY + t.y0 - t.height/2

            ]]–

        elseif phase == “ended” or phase == “cancelled” then

            --transBack(t.path,corner.blX,corner.blY)

            --debug.text=t.path.y2

            display.getCurrentStage():setFocus( t, nil )

            t.isFocus = false

            

        end

    end

end

rect:addEventListener(“touch”,dragRect)

[/lua]

Click and Drag (it will use the bottom-left corner).

What you’ll notice aswell:

First time you start it, it will show a black screen! (it doesn’t show up any display.newRect - tested in other apps aswell)

After reloading (apple+r), it shows up and you can test it out.

I would really like this feature the most, but I’m a bit afraid with those bugs. And it seems we can’t make a build with that beta, right?

Do you have code that we can use to reproduce?

Sure:

[lua]

–local trans = require(“trans”)

display.setDefault( “v1Compatibility”, false )

display.setStatusBar( display.HiddenStatusBar )

local centerX,centerY = display.contentCenterX,display.contentCenterY

local rect = display.newRect(0,0,200,200)

rect.anchorX,rect.anchorY = 0.5,.5

rect.x,rect.y = centerX,centerY

rect.rPath = rect.path

rect:setFillColor(0,.5,1)

local corner = {}

corner.tlX = rect.path[‘x1’]

corner.trX = rect.path[‘x3’]

corner.blX = rect.path[‘x2’]

corner.brX = rect.path[‘x4’]

corner.tlY = rect.path[‘y1’]

corner.trY = rect.path[‘y3’]

corner.blY = rect.path[‘y2’]

corner.brY = rect.path[‘y4’]

local debug  = display.newText(“Debug”, 20, 55, native.systemFont, 32)

debug:setTextColor(255,0,0)

debug.x,debug.y = centerX,50

local debugTxt = “”

local function transBack(obj,xx2,yy2)

    transition.to(obj,{time=500,x2=xx2,y2=yy2,transition=easing.outBounce})

end

local function dragRect(event)

    local t = event.target

    local phase = event.phase

    if phase == “began” then

        display.getCurrentStage():setFocus( t, event.id )

        t.isFocus = true

    elseif t.isFocus then

        if phase == “moved” then

            t.x0 = event.x - t.x

            t.y0 = event.y - t.y

            t.path.x2 = corner.blX + t.x0 + t.width/2

            t.path.y2 = corner.blY + t.y0 - t.height/2

            --[[

            t.path.x3 = corner.blX + t.x0 - t.width/2

            t.path.y3 = corner.blY + t.y0 - t.height/2

            ]]–

        elseif phase == “ended” or phase == “cancelled” then

            --transBack(t.path,corner.blX,corner.blY)

            --debug.text=t.path.y2

            display.getCurrentStage():setFocus( t, nil )

            t.isFocus = false

            

        end

    end

end

rect:addEventListener(“touch”,dragRect)

[/lua]

Click and Drag (it will use the bottom-left corner).

What you’ll notice aswell:

First time you start it, it will show a black screen! (it doesn’t show up any display.newRect - tested in other apps aswell)

After reloading (apple+r), it shows up and you can test it out.

I would really like this feature the most, but I’m a bit afraid with those bugs. And it seems we can’t make a build with that beta, right?

Okay, thanks! On our radar.

@chrizzzly

We fixed a few issues here that will be available in the next alpha seed that were impacting you. The initial blank view issue should be resolved, the path selection area now includes the updated path for selection.

There is a slight update to the sample code you provided to make everything work with the new upcoming seed.

[lua]

local function dragRect(event)

    local t = event.target

    local phase = event.phase

    if phase == “began” then

        display.getCurrentStage():setFocus( t, event.id )

        t.isFocus = true

        t.x2 = event.x

        t.y2 = event.y

    elseif t.isFocus then

        if phase == “moved” then

            print( event.x,  event.y, event.x - t.x2, event.y - t.y2 )

            t.path.x2 = t.path.x2 + ( event.x - t.x2 )

            t.path.y2 = t.path.y2 + ( event.y - t.y2 )

            t.x2 = event.x

            t.y2 = event.y

            – t.path.x2 = corner.blX + t.x0 + t.width/2

            – t.path.y2 = corner.blY + t.y0 - t.height/2

            --[[

            t.path.x3 = corner.blX + t.x0 - t.width/2

            t.path.y3 = corner.blY + t.y0 - t.height/2

            ]]–

        elseif phase == “ended” or phase == “cancelled” then

            --transBack(t.path,corner.blX,corner.blY)

            --debug.text=t.path.y2

            display.getCurrentStage():setFocus( t, nil )

            t.isFocus = false

            

        end

    end

end

[/lua]

Okay, thanks! On our radar.

@chrizzzly

We fixed a few issues here that will be available in the next alpha seed that were impacting you. The initial blank view issue should be resolved, the path selection area now includes the updated path for selection.

There is a slight update to the sample code you provided to make everything work with the new upcoming seed.

[lua]

local function dragRect(event)

    local t = event.target

    local phase = event.phase

    if phase == “began” then

        display.getCurrentStage():setFocus( t, event.id )

        t.isFocus = true

        t.x2 = event.x

        t.y2 = event.y

    elseif t.isFocus then

        if phase == “moved” then

            print( event.x,  event.y, event.x - t.x2, event.y - t.y2 )

            t.path.x2 = t.path.x2 + ( event.x - t.x2 )

            t.path.y2 = t.path.y2 + ( event.y - t.y2 )

            t.x2 = event.x

            t.y2 = event.y

            – t.path.x2 = corner.blX + t.x0 + t.width/2

            – t.path.y2 = corner.blY + t.y0 - t.height/2

            --[[

            t.path.x3 = corner.blX + t.x0 - t.width/2

            t.path.y3 = corner.blY + t.y0 - t.height/2

            ]]–

        elseif phase == “ended” or phase == “cancelled” then

            --transBack(t.path,corner.blX,corner.blY)

            --debug.text=t.path.y2

            display.getCurrentStage():setFocus( t, nil )

            t.isFocus = false

            

        end

    end

end

[/lua]