Hello all,
So I wanted to create an app in which there is a red square and two arrow keys. When the user holds on either arrow key, the square moves in that direction. I tried to do this using square.animate in which the square is a view, but the animate doesn't seem to be working. What happens is that the square will move in either direction once and then just get stuck at the new position. Does anyone know a different way to approach this problem? Also, which event listener should I be using? (I used touchstart earlier)
Thanks in advance!
2 Answers
Accepted Answer
Try something like this if u want
left_button.addeventlistener('touchstart', function() { square.animate_left() }) left_button.addeventlistener('touchend', function() { square.animate__to_original() }) left_button.addeventlistener('touchcancel', function() { square.animate__to_original() }) right_button.addeventlistener('touchstart', function() { square.animate_right() }) right_button.addeventlistener('touchstart', function() { square.animate__to_original() }) right_button.addeventlistener('touchcancel', function() { square.animate__to_original() })COmment below if you want something else to happen !!!
From here you can get more information about animations
http://cssgallery.info/seven-days-with-titanium-day-6%E2%80%93animations-and-transforms/
Your Answer
This question has been locked and cannot accept new answers.