@@ -21,39 +21,40 @@ function colorForTouch(touch) {
21
21
return color ;
22
22
}
23
23
24
- // keep track of the ongoing touches
25
- var onGoingTouches = { } ;
26
- function touchDown ( event ) {
27
- event . touches . forEach ( function ( touch ) {
28
- onGoingTouches [ touch . identifier ] = touch ;
29
- onGoingTouches [ touch . identifier ] . color = colorForTouch ( touch ) ;
30
- // draw circle at start
31
- gamejs . graphics . circle ( display , '#ff0000' , touch . pos , 5 ) ;
32
- } ) ;
33
- } ;
24
+ function main ( ) {
25
+ // minus margin and footer
26
+ var display = gamejs . display . setMode ( [ document . body . clientWidth - 50 , window . innerHeight - 120 ] ) ;
34
27
35
- function touchUp ( event ) {
36
- event . touches . forEach ( function ( touch ) {
37
- onGoingTouches [ touch . identifier ] = undefined ;
38
- // draw circle at end
39
- gamejs . graphics . circle ( display , '#ff0000' , touch . pos , 5 ) ;
40
- } )
41
- } ;
42
28
43
- function touchMotion ( event ) {
44
- event . touches . forEach ( function ( touch ) {
45
- // keep track of previous and current position
46
- var aTouch = onGoingTouches [ touch . identifier ] ;
47
- aTouch . lastPos = aTouch . pos ;
48
- aTouch . pos = touch . pos ;
49
- // draw movement
50
- gamejs . graphics . line ( display , aTouch . color , aTouch . lastPos , aTouch . pos , 3 ) ;
51
- } )
52
- } ;
29
+ // keep track of the ongoing touches
30
+ var onGoingTouches = { } ;
31
+ function touchDown ( event ) {
32
+ event . touches . forEach ( function ( touch ) {
33
+ onGoingTouches [ touch . identifier ] = touch ;
34
+ onGoingTouches [ touch . identifier ] . color = colorForTouch ( touch ) ;
35
+ // draw circle at start
36
+ gamejs . graphics . circle ( display , '#ff0000' , touch . pos , 5 ) ;
37
+ } ) ;
38
+ } ;
53
39
54
- function main ( ) {
55
- // minus margin and footer
56
- var display = gamejs . display . setMode ( [ document . body . clientWidth - 50 , window . innerHeight - 120 ] ) ;
40
+ function touchUp ( event ) {
41
+ event . touches . forEach ( function ( touch ) {
42
+ onGoingTouches [ touch . identifier ] = undefined ;
43
+ // draw circle at end
44
+ gamejs . graphics . circle ( display , '#ff0000' , touch . pos , 5 ) ;
45
+ } )
46
+ } ;
47
+
48
+ function touchMotion ( event ) {
49
+ event . touches . forEach ( function ( touch ) {
50
+ // keep track of previous and current position
51
+ var aTouch = onGoingTouches [ touch . identifier ] ;
52
+ aTouch . lastPos = aTouch . pos ;
53
+ aTouch . pos = touch . pos ;
54
+ // draw movement
55
+ gamejs . graphics . line ( display , aTouch . color , aTouch . lastPos , aTouch . pos , 3 ) ;
56
+ } )
57
+ } ;
57
58
58
59
gamejs . event . onTouchDown ( touchDown ) ;
59
60
gamejs . event . onTouchUp ( touchUp ) ;
0 commit comments