Connecting the dots
Our app already has a clear screen function but still draws just circles. Let's change it so that we can draw lines instead.
To follow continuous touch events (click-and-drag), we'll need to add a new event listener, on_touch_move
. Every time the callback is invoked, it receives the latest point where the event occurred.
If we only had a single line going at every moment (like typically done on a desktop, since there is only one mouse pointer anyway), we could save the line we're currently drawing in self.current_line
. But since we're aiming at multitouch support from the very beginning, we'll take another approach and store every line being drawn in the corresponding touch
variable itself.
This works because for every continuous touch from start to end, all callbacks receive the same touch
object. There is also a touch.ud
property of the type dict
(where ud
is short for user data), which is specifically tailored to keep touch-specific attributes...