Skip to end of metadata
Go to start of metadata

 

dmc_multitouch not on github Master branch
Though dmc_multitouch is already in use by other developers, it hasn't officially been released yet. so, in order to find it in the github repo, you will need to switch to its development branch. the icon to the right is already linked to that branch. Happy Coding ! – dmc

Table of Contents

Import

Import the library module like so:

Import DMC Multitouch

Overview

You layer on the functionality desired by calling the following function one or more times:

Parameter Notes
object corona display object
 
this is the Corona display object to be controlled by the touch interface
action "move", "rotate", "scale" (string)
 
action is a string defining the behavior to add to the object
touch "single", "multi", { "single", "multi" } (string or table)
 
touch defines how the behavior is controlled, either with a single touch or with a multi-touch gesture. a table can be used to define the action if it's to be controlled by both types of touch.
params { <action constraints> } (table)
 
params is an optional parameter which contains properties used to constrain the behavior of the action. for example, the action "move" might have an upper bounds in the y-axis which movement cannot pass.
 
{ yBounds = { 120, nil } }

Most behaviors can be added at the same time on an object except for a few certain cases. As you'll see in the following chart, some of the single-touch actions are not compatible. for example, starting on the left column, say i wanted to have the action single-touch Move ( M(1) ) added to my object. as i go along the row to the right, i can see that single-touch Rotate ( R(1) ) and single-touch Scale ( S(1) ) are not compatible.

  M(1) M( x ) R(1) R( x ) S(1) S( x )
M(1)
M( x )
R(1)
R( x )
S(1)
S( x )

Example

Here's an example of applying several behaviors to a single object 

Example

Functions

move

MultiTouch.activate( obj, "move", touch [, params] )

The params parameter is a table which can have one one or more of the following properties. These properties are used to constrain scaling.

Here are the options:

Constraint Params Notes
xBounds  
yBounds  
constrainAngle  

scale

MultiTouch.activate( obj, "scale", touch [, params] )

The params parameter is a table which can have one one or more of the following properties. These properties are used to constrain scaling.

Here are the options:

Constraint Params Notes
minScale (number)
lower limit for the scale of the object.
maxScale (number)
upper limit for the scale of the object.

rotate

MultiTouch.activate( obj, "rotate", touch [, params] )

The params parameter is a table which can have one one or more of the following properties. These properties are used to constrain scaling.

Here are the options:

Constraint Params Notes
minAngle (number)
lower limit for the angle of the object rotation. can be negative or positive.
maxAngle (number)
upper limit for the angle of the object rotation. can be negative or positive.

Event

any action will fire off events for movement. an event listener can be attached to the object to find out about the events.

property note
x x coordinate of the object's current position
y y coordinate of the object's current position
xDelta change in x coordinate since the beginning of the new touch
yDelta change in y coordinate since the beginning of the new touch
direction "clockwise", "counter_clockwise", nil
 
will be set on rotation, or nil
angleDelta change in angle since the beginning of the new touch
distanceDelta change in the distance from the beginning of the move to the current position
 
pythagorean theorem – sqrt( xDelta^2 + yDelta^2 )
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.