Getting touch x and y coordinates on 0.8.0
Hello
I'm trying to develop an app that will work on most iPhone os versions.
I've noticed that since 0.8.1 there's no support for os 3.0 and below so I wanted to create the app using TD 0.8.0.
I couldn't find the original docs for that version.
What I'm trying to achieve is to get the x,y coordinates of the first touch/swipe/drag the user makes.
I've tried using transparent PNG's for buttons but I get the pressed effect on them which is a problem.
Is there a way to get the touch x,y coordinates like in later versions?
Or to suppress the effect on the buttons?
4 Answers
-
If you're using 0.8.x, the best source of documentation on touch events actually comes from the Safari dev center - there are docs out there on Webkit's touch events, which you can use for this purpose. Bear in mind that 0.8.x will not be receiving any upgrades from Appcelerator, though…
-
In a webView you can use :
var touch=e.touches[0]; var x=touch.clientX; var y=touch.clientY;
where e come from :
yourIdElement.ontouchstart=function(e)
but there is also : ontouchmove, ontouchend etc…
-
I've managed to find the answer through other forums.
It's done through regular touch events and not TI events but it works fine.
I've enclosed the code just in case someone else will be looking for this.document.addEventListener('touchstart', function(event) { event.preventDefault(); var touch = event.touches[0]; var a = Titanium.UI.createAlertDialog({ title:'Alert Test', message:"Touch x:" + touch.pageX + ", y:" + touch.pageY}); a.show(); }, false);
Shahar
-
do any one knows how to use titanium to build tic tac game for android