Coder Social home page Coder Social logo

timultitouch's Introduction

Multitouch module for Appcelerator Titanium (iPhone & iOS)

Handle multi touch events inside your iOS applications.

INSTALL

If your Titanium SDK is installed in /Library/Application Support/Titanium:

./build.py && rm -Rf /Library/Application\ Support/Titanium/modules/iphone/org.urish.titanium.multitouch/ && unzip org.urish.titanium.multitouch-iphone-1.2.zip -d /Library/Application\ Support/Titanium/

If your Titanium SDK is installed under your home directory:

./build.py && rm -Rf ~/Library/Application\ Support/Titanium/modules/iphone/org.urish.titanium.multitouch/ && unzip org.urish.titanium.multitouch-iphone-1.2.zip -d ~/Library/Application\ Support/Titanium/

If you have another Titanium Mobile SDK version, please change the value of the "TITANIUM_SDK_VERSION" property in titanium.xcconfig to match your installed version.

PRECOMPILED VERSION

If you would rather not compile the module yourself, you can simply download a precompiled version. Precompiled versions are available here:

Precompiled version of the TiMultitouch module

HOW TO USE IT

  1. Add the multitouch module to your tiapp.xml: inside the <modules> tag add the following line: <module version="1.2">org.urish.titanium.multitouch</module>
  2. Add the following code in the beginning of your app.js: require("org.urish.titanium.multitouch");
  3. To enable multitouch for a window or a view, add an empty event listener to the 'singletap' event (see example below).
  4. Now your touchstart/touchmove/touchend/touchcancel events will contain a new field: "points". This field is a dictionary with information about the active touches: the key is the id of the touch, and the value is an object with the following properties: 'x', 'y' and 'globalPoint'.

WATCH IN ACTION

The TiMultiTouch module is used in the Zampoña iOS application. The application resembles a peruvian panflute and uses the TiMultiTouch to enable playing two or more notes simultaneously. You can get it for free from Zampona on iTunes.

CODE EXAMPLE

require("org.urish.titanium.multitouch");

win.multitouch = true;

win.addEventListener("touchstart", function(event) {
	Ti.API.info("Touches started, points: " + JSON.stringify(event.points));
	
	// Sample code for interating the points:
	for (var pointName in event.points) {
		Ti.API.info("Point " + pointName + " x=" + event.points[pointName].x
			+ ", y=" + event.points[pointName].y);
	}
	
	// You can use the above for the other events as well (touchmove, 
	// touchend, touchcancel). Note that event.points is not an array, 
	// so you should iterate it like the example above, and not as an array.
});

win.addEventListener("touchmove", function(event) {
	Ti.API.info("Touches moved, points: " + JSON.stringify(event.points));
});

win.addEventListener("touchend", function(event) {
	Ti.API.info("Touches ended, points: " + JSON.stringify(event.points));
});

win.addEventListener("touchcanceled", function(event) {
	Ti.API.info("Touches canceled, points: " + JSON.stringify(event.points));
});

For more info, please check app.js

LICENSE

MIT License

COPYRIGHT

  • 2011, 2012 Uri Shaked (urish)
  • 2011 Jose Fernandez (magec) github.com/magec (small change and tested in 1.6.2)
  • 2010 Yuchiro MASUI (masuidrive) [email protected]

timultitouch's People

Contributors

magec avatar masuidrive avatar urish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.