Hi,
Could you explain me how works touchmove event plus.
in the example in the kithchensink (basic_animation)..for moving the circle. there is this code :
circle.addEventListener('touchmove', function(e) { Ti.API.debug('Our event tells us the center is ' + e.x + ', ' + e.y ); var newX = e.x + circle.animatedCenter.x - circle.width; var newY = e.y + circle.animatedCenter.y - circle.height; circle.animate({left:newX,top:newY, duration:1}); });for me, it is more intuitive with this code (for y) :
circle.addEventListener('touchmove', function(e) { Ti.API.debug('Our event tells us the center is ' + e.x + ', ' + e.y ); var newY = e.y; circle.animate({left:newX,top:newY, duration:1}); });because e.y is the current position so circle is moved to the current position... what do you think ?
thanks
1 Answer
The difference between the first example and yours is that the circle will get positioned from the center of the circle in the first example, but in your example, the circle will get positioned from the top left coordinate of circle. So both examples will drag the circle just fine, the only difference will be whether the circle gets dragged from the top left of the circle or the center of the circle.
Your Answer
Think you can help? Login to answer this question!