Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# Main
- -- App 01 - Touch
- -- This program demonstrates touch and touch events.
- -- Bruce Elliott
- -- April 2013
- -- Use this function to perform your initial setup
- function setup()
- -- Touch Demo
- -- When the iPad screen is touched the
- -- event is recorded. The data type
- -- touch is used to record the information
- -- generated. The global variable
- -- CurrentTouch can be used to recover
- -- that information
- -- Here the function myTouch() is used to
- -- clear the screen and display the data
- -- data updates quickly (immediately)
- -- If you watch status it starts at 0,
- -- changes and stays at 1,
- -- then displays 2 when touch stops
- end
- -- This function gets called once every frame
- function draw()
- -- This sets a dark background color
- background(40, 40, 50)
- myTouch()
- -- This sets the line thickness
- strokeWidth(5)
- end
- function myTouch()
- if CurrentTouch.state > -1 then
- -- Clear the Output screen
- output.clear()
- -- Display CurrentTouch data
- print("touch id: "..CurrentTouch.id)
- print("touch x: "..CurrentTouch.x)
- print("touch y: "..CurrentTouch.y)
- print("touch prevx: "..CurrentTouch.prevX)
- print("touch prevx: "..CurrentTouch.prevY)
- print("touch deltax: "..CurrentTouch.deltaX)
- print("touch deltay: "..CurrentTouch.deltaY)
- print("touch state: "..CurrentTouch.state)
- print("touch tapcount: "..CurrentTouch.tapCount)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement