Skip to content

Commit 11dc49b

Browse files
author
Ben D'Angelo
committed
small tweak
1 parent 9a22866 commit 11dc49b

File tree

1 file changed

+28
-0
lines changed
  • templates/circle/scripts/scenes

1 file changed

+28
-0
lines changed

templates/circle/scripts/scenes/home.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)