Skip to content

Commit b8f9e5d

Browse files
committed
improve movement
1 parent d8cbbdd commit b8f9e5d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

04-Breakout-Game/script.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function keyRight() {// pressed right arrow key
318318
var touchXstart = null;
319319
var previousPosition = canvas.width/2-paddle.w/2;
320320
function actionStart(e){
321-
e.preventDefault();
321+
// e.preventDefault();
322322
//判断是鼠标左键点击还是触摸
323323
if(e.touches && touchXstart == null){//如果是触摸 touchXstart等于第一个touch点的x坐标
324324
touchXstart = e.touches[0].pageX;
@@ -327,7 +327,7 @@ function actionStart(e){
327327
}
328328
}
329329
function actionEnd(e){
330-
e.preventDefault();
330+
//e.preventDefault();
331331
touchXstart = null;
332332
previousPosition = paddle.x;
333333
}
@@ -337,7 +337,7 @@ function actionMove(e){
337337
//判断是鼠标左键点击还是触摸
338338
if(touchXstart != null){
339339
if(e.touches ){//如果是触摸 dist等于第一个touch点的x坐标x相对touchXstart的移动距离
340-
dist = e.touches[0].pageX - touchXstart;
340+
dist =( e.touches[0].pageX - touchXstart)*2;
341341
}else{//如果是鼠标 dist等于鼠标的x坐标x相对touchXstart的移动距离
342342
dist = e.pageX - touchXstart;
343343
}

0 commit comments

Comments
 (0)