Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# Main
- -- App 01b - Touch
- -- This program demonstrates touch and touch events.
- -- Bruce Elliott
- -- April 2013
- -- Use this function to perform your initial setup
- function setup()
- print("Touch Demo")
- print("When the iPad screen is touched the")
- print("event is recorded. In A01 we had to ")
- print("call myEvent from inside draw()")
- print("Here we will rename the function to")
- print("touched and use the variable touch")
- -- With multiple taps, the number updates
- -- quickly
- -- touch.id update but is not a usable number
- 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 touched(touch)
- if touch.state == BEGAN or touch.state == MOVING then
- output.clear()
- -- Do your drawing here
- print("touch id: "..touch.id)
- print("touch x: "..touch.x)
- print("touch y: "..touch.y)
- print("touch prevx: "..touch.prevX)
- print("touch prevx: "..touch.prevY)
- print("touch deltax: "..touch.deltaX)
- print("touch deltay: "..touch.deltaY)
- print("touch state: "..touch.state)
- print("touch tapcount: "..touch.tapCount)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement