Permalink
Browse files

small tweak

  • Loading branch information...
1 parent 9a22866 commit 11dc49b68b67adc87e9ca759e1758919e47384be @bendangelo committed Mar 23, 2012
Showing with 28 additions and 0 deletions.
  1. +28 −0 templates/circle/scripts/scenes/home.js
@@ -31,4 +31,32 @@ re.scene('home')
.alignTop(5)
.alignLeft(5);
+ //stop the browser from moving around
+ re.preventDefault('left right up down');
+
+ //create new circle on canvas
+ re.e('circle align update')
+ .attr({
+ radius:10,
+ speed:15,
+ color:'#ff0000'
+ })
+ //from align component
+ .align()
+ .on('update', function(){
+
+ //move on keypressed
+ if(re.pressed('a', 'left')) this.posX -= this.speed;
+ if(re.pressed('d', 'right')) this.posX += this.speed;
+
+ if(re.pressed('w', 'up')) this.posY -= this.speed;
+ if(re.pressed('s', 'down')) this.posY += this.speed;
+
+ });
+
+ //add help text
+ re.e('text align')
+ .text('Use WASD or arrow keys to move the circle')
+ .alignTop(5)
+ .alignLeft(5);
});

0 comments on commit 11dc49b

Please sign in to comment.