User Tools

Site Tools


gestures:touch:complex:velocity-direction:n-swipe

N-Swipe

(Touch → Complex → Velocity & Direction → Simple N Point Swipe Gesture “N-Swipe”)

The 'n-swipe' gesture can be activated by any number of touch points. When a touch down is recognized on a touch object, the velocity and acceleration of the touch points are tracked. If acceleration of the cluster is below the acceleration threshold a swipe event is dispatched.

The acceleration threshold is defined in the “<variables>” tag in the “<analysis>” block. In the example below the var=“etm_ddx” has an allowable maximum value of var_max=“1”. This sets maximum value of 1 on the variable “etm_ddx” (mean acceleration in the x direction). If the average group acceleration of the touch point cluster is greater than 1 pixle per second per second, the return value of the dimension is set to zero. If both dimensions are have zero value the gesture will be put in an inactive state and no event will dispatched.

<Gesture id="n-swipe" type="swipe">
<!--The 'n-swipe' gesture can be activated by any number of touch points. When a touch down is recognized on a touch object, the velocity and acceleration of the touch points are tracked. If acceleration of the cluster is below the acceleration threshold a swipe event is dispatched. -->
    <match>
        <action>
          <initial>
              <cluster point_number="0" point_number_min="1" point_number_max="5" acceleration_max="0.5"/>
              <event touch_event="touchEnd"/>
          </initial>
        </action>
    </match>
    <analysis>
        <algorithm class="kinemetric" type="discrete">
          <library module="swipe" />
          <variables>
              <property id="swipe_dx" var="etm_ddx" return="etm_dx" var_max="1"/>
              <property id="swipe_dy" var="etm_ddy" return="etm_dy" var_max="1"/>
          </variables>
          <returns>
              <property id="swipe_dx" result="etm_dx"/>
              <property id="swipe_dy" result="etm_dy"/>
          </returns>
        </algorithm>
    </analysis>  
    <mapping>
        <update dispatch_type="discrete" dispatch_mode="cluster_remove" dispatch_reset="cluster_remove">
          <gesture_event  type="swipe">
              <property ref="swipe_dx" target=""/>
              <property ref="swipe_dy" target=""/>
          </gesture_event>
        </update>
    </mapping>
</Gesture>

When the matching criteria for this gesture is met and the values returned from analysis are below the acceleration threshold the gesture object as defined by the above GML will return the swipe velocity “etm_dx” and “etm_dy” to the dimension “swipe_dx” and “swipe_dy” respectively. These dimension values can be directly accessed via the gesture event object.

gestures/touch/complex/velocity-direction/n-swipe.txt · Last modified: 2019/01/29 19:07 (external edit)