This version of dmc-gesture has been replaced by version 2.0

Get quickly up-and-running with dmc_gesture.

Requires

this library requires dmc_touchmanager

move()

{code:language=none}local Touch = require( "dmc_touch" ) Touch.move( object, params )


### Parameters

object is a corona display object,

params is a lua table with any of the following parameters:

*xBounds*

high and low x bounds where xLow < xHigh, or either can be nil
{code:language=none}xBounds = { xLow, xHigh }, -- eg, { 20, 400 }, { nil, 280 }, { 100, nil }

yBounds

high and low y bounds where yLow < yHigh, or either can be nil {code:language=none}yBounds = { yLow, yHigh }, -- eg, { 20, 400 }, { nil, 280 }, { 100, nil }``` constrainAngle

angle can be any number

recommend that if a bound is desired with constrainAngle, only ONE of x or y bounds be used.

if angle <= 45 degrees (ie, closer to the x axis), then xBounds should be used.

if angle > 45 degrees (ie, closer to the y axis), then yBounds should be used. {code:language=none}constrainAngle = 45, -- eg, 0, 23, -15, 90

{code:language=none}Touch.move( o, { constrainAngle = 0 } )
Touch.move( o, { xBounds = { 120, nil }, yBounds = { 200, 280 } } )

events

Touch.MOVE_EVENT = "move_event"

o:addEventListener( Touch.MOVE_EVENT, callback ) o:addEventListener( "move_event", callback ) {code:language=none}event = { name = Touch.MOVE_EVENT, phase = "began", "moved", "ended", "canceled" target = , moveX, moveY }```

swipe()

Touch.swipe( object, params )

object is a corona display object,

params is a lua table with any of the following parameters:

limitAngle (neg/pos integer)

angle from axis, defines range of valid swipes

(default 20 deg)

swipeLength (positive integer)

minimum length for a valid swipe. must be greater than 10.

(default 150)

useStrictBounds (boolean)

whether or not the swipe has to end within the boundaries of the swipable object.

default (false)

events

Touch.SWIPE_EVENT = "swipe_event"

o:addEventListener( Touch.SWIPE_EVENT, callback ) o:addEventListener( "swipe_event", callback )

if event.direction is nil, then that means one of the following failed:

  • to short the swipe wasn't long enough to be registered as a valid swipe (swipeLength or useStrictBounds)
  • wrong angle the angle of the swipe didn't fall within the valid angle range (limitAngle) {code:language=none}event = { name = Touch.SWIPE_EVENT, phase = "began", "moved", "ended", "canceled" target = , direction = "left", -- 'left', 'right', 'up', 'down', nil

    touch = { xStart, yStart, x, y }, swipe = { angle, length } } ```