Advertisement
br1wr2el3

App 01 - Touch using CurrentTouch

Apr 21st, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. --# Main
  2. -- App 01 - Touch
  3.  
  4. -- This program demonstrates touch and touch events.
  5.  
  6. -- Bruce Elliott
  7. -- April 2013
  8.  
  9.  
  10. -- Use this function to perform your initial setup
  11. function setup()
  12. -- Touch Demo
  13. -- When the iPad screen is touched the
  14. -- event is recorded. The data type
  15. -- touch is used to record the information
  16. -- generated. The global variable
  17. -- CurrentTouch can be used to recover
  18. -- that information
  19. -- Here the function myTouch() is used to
  20. -- clear the screen and display the data
  21. -- data updates quickly (immediately)
  22. -- If you watch status it starts at 0,
  23. -- changes and stays at 1,
  24. -- then displays 2 when touch stops
  25. end
  26.  
  27. -- This function gets called once every frame
  28. function draw()
  29. -- This sets a dark background color
  30. background(40, 40, 50)
  31. myTouch()
  32. -- This sets the line thickness
  33. strokeWidth(5)
  34. end
  35.  
  36. function myTouch()
  37. if CurrentTouch.state > -1 then
  38. -- Clear the Output screen
  39. output.clear()
  40. -- Display CurrentTouch data
  41. print("touch id: "..CurrentTouch.id)
  42. print("touch x: "..CurrentTouch.x)
  43. print("touch y: "..CurrentTouch.y)
  44. print("touch prevx: "..CurrentTouch.prevX)
  45. print("touch prevx: "..CurrentTouch.prevY)
  46. print("touch deltax: "..CurrentTouch.deltaX)
  47. print("touch deltay: "..CurrentTouch.deltaY)
  48. print("touch state: "..CurrentTouch.state)
  49. print("touch tapcount: "..CurrentTouch.tapCount)
  50. end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement