Advertisement
br1wr2el3

App 01b - Touch with BEGAN

Apr 21st, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1.  
  2. --# Main
  3. -- App 01b - Touch
  4.  
  5. -- This program demonstrates touch and touch events.
  6.  
  7. -- Bruce Elliott
  8. -- April 2013
  9.  
  10.  
  11. -- Use this function to perform your initial setup
  12. function setup()
  13. print("Touch Demo")
  14. print("When the iPad screen is touched the")
  15. print("event is recorded. In A01 we had to ")
  16. print("call myEvent from inside draw()")
  17. print("Here we will rename the function to")
  18. print("touched and use the variable touch")
  19. -- With multiple taps, the number updates
  20. -- quickly
  21. -- touch.id update but is not a usable number
  22.  
  23. end
  24.  
  25. -- This function gets called once every frame
  26. function draw()
  27. -- This sets a dark background color
  28. background(40, 40, 50)
  29. -- myTouch()
  30. -- This sets the line thickness
  31. strokeWidth(5)
  32. end
  33.  
  34. function touched(touch)
  35.  
  36. if touch.state == BEGAN or touch.state == MOVING then
  37. output.clear()
  38. -- Do your drawing here
  39. print("touch id: "..touch.id)
  40. print("touch x: "..touch.x)
  41. print("touch y: "..touch.y)
  42. print("touch prevx: "..touch.prevX)
  43. print("touch prevx: "..touch.prevY)
  44. print("touch deltax: "..touch.deltaX)
  45. print("touch deltay: "..touch.deltaY)
  46. print("touch state: "..touch.state)
  47. print("touch tapcount: "..touch.tapCount)
  48. end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement