File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
templates/circle/scripts/scenes Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -31,4 +31,32 @@ re.scene('home')
3131 . alignTop ( 5 )
3232 . alignLeft ( 5 ) ;
3333
34+ //stop the browser from moving around
35+ re . preventDefault ( 'left right up down' ) ;
36+
37+ //create new circle on canvas
38+ re . e ( 'circle align update' )
39+ . attr ( {
40+ radius :10 ,
41+ speed :15 ,
42+ color :'#ff0000'
43+ } )
44+ //from align component
45+ . align ( )
46+ . on ( 'update' , function ( ) {
47+
48+ //move on keypressed
49+ if ( re . pressed ( 'a' , 'left' ) ) this . posX -= this . speed ;
50+ if ( re . pressed ( 'd' , 'right' ) ) this . posX += this . speed ;
51+
52+ if ( re . pressed ( 'w' , 'up' ) ) this . posY -= this . speed ;
53+ if ( re . pressed ( 's' , 'down' ) ) this . posY += this . speed ;
54+
55+ } ) ;
56+
57+ //add help text
58+ re . e ( 'text align' )
59+ . text ( 'Use WASD or arrow keys to move the circle' )
60+ . alignTop ( 5 )
61+ . alignLeft ( 5 ) ;
3462} ) ;
You can’t perform that action at this time.
0 commit comments