quyueting пре 5 година
родитељ
комит
984afc3b79
1 измењених фајлова са 33 додато и 29 уклоњено
  1. 33 29
      minigame/WebContent/js/main.js

+ 33 - 29
minigame/WebContent/js/main.js

@@ -485,7 +485,7 @@ function handleComplete(evt, comp) {
             materialAnim(exportRoot.blackboard.material1, 300, 180, function() {
                 exportRoot.blackboard.material1.x -=300;
                 exportRoot.blackboard.material1.y -=180;
-                $(".shake-mode").show();
+                // $(".shake-mode").show();
                 shakeInit();
             });
         })
@@ -498,7 +498,7 @@ function handleComplete(evt, comp) {
             materialAnim(exportRoot.blackboard.material2, 120, 180, function() {
                 exportRoot.blackboard.material2.x -=120;
                 exportRoot.blackboard.material2.y -=180;
-                $(".shake-mode").show();
+                // $(".shake-mode").show();
                 shakeInit();
             });
         })
@@ -511,7 +511,7 @@ function handleComplete(evt, comp) {
             materialAnim(exportRoot.blackboard.material3, -30, 180, function() {
                 exportRoot.blackboard.material3.x +=30;
                 exportRoot.blackboard.material3.y -=180;
-                $(".shake-mode").show();
+                // $(".shake-mode").show();
                 shakeInit();
             });
         })
@@ -563,35 +563,10 @@ function handleComplete(evt, comp) {
             alert('您的手机不支持摇一摇功能!');
         }
 
-        setTimeout(function(){
-            window.removeEventListener('devicemotion', deviceMotionHandler, false);
-            exportRoot.pot.hsr.play();
-            exportRoot.btn3.alpha = 1;
-            btnAnim(exportRoot.btn3);
-            exportRoot.btn3.addEventListener("mousedown",function(){
-                exportRoot.btn3.removeAllEventListeners();
-                var href = document.location.href + "&type=" + chooseType + "&food=" + dishIndex;
-                history.pushState("", "Title", href);
-                $(".poster-mode").fadeIn();
-            })
-
-
-            if(dishIndex == 0){
-                exportRoot.pot.hsr.gotoAndStop(1);
-            }else if(dishIndex == 1){
-                exportRoot.pot.qcdf.gotoAndStop(1);
-            }else if(dishIndex == 2){
-                exportRoot.bowl.oil.alpha = 0;
-                exportRoot.plate['swy_icon1'].gotoAndStop(2);
-            }else{
-                exportRoot.pot.ymc.gotoAndStop(1);
-            }
-            $(".shake-mode").fadeOut();
-        },3000)
         //获取加速度信息
         //通过监听上一步获取到的x, y, z 值在一定时间范围内的变化率,进行设备是否有进行晃动的判断。
         //而为了防止正常移动的误判,需要给该变化率设置一个合适的临界值。
-        var SHAKE_THRESHOLD = 8000; //阈值越大,触发摇晃事件时手机摇晃的程度越剧烈
+        var SHAKE_THRESHOLD = 10000; //阈值越大,触发摇晃事件时手机摇晃的程度越剧烈
         var last_update = 0;
         var x, y, z, last_x = 0,
             last_y = 0,
@@ -608,6 +583,31 @@ function handleComplete(evt, comp) {
                 z = acceleration.z;
                 var speed = Math.abs(x + y + z - last_x - last_y - last_z) / diffTime * 10000;
                 if (speed > SHAKE_THRESHOLD) {
+                    $(".shake-mode").show();
+                    setTimeout(function(){
+                        window.removeEventListener('devicemotion', deviceMotionHandler, false);
+                        exportRoot.pot.hsr.play();
+                        exportRoot.btn3.alpha = 1;
+                        btnAnim(exportRoot.btn3);
+                        exportRoot.btn3.addEventListener("mousedown",function(){
+                            exportRoot.btn3.removeAllEventListeners();
+                            $(".poster-mode").fadeIn();
+                        })
+
+
+                        if(dishIndex == 0){
+                            exportRoot.pot.hsr.gotoAndStop(1);
+                        }else if(dishIndex == 1){
+                            exportRoot.pot.qcdf.gotoAndStop(1);
+                        }else if(dishIndex == 2){
+                            exportRoot.bowl.oil.alpha = 0;
+                            exportRoot.plate['swy_icon1'].gotoAndStop(2);
+                        }else{
+                            exportRoot.pot.ymc.gotoAndStop(1);
+                        }
+                        $(".shake-mode").fadeOut();
+                    },3000)
+
                     //dosomething
                     $("#fire").addClass("anim-time");
                 }else{
@@ -622,6 +622,10 @@ function handleComplete(evt, comp) {
     }
 
 
+
+
+
+
     //Registers the "tick" event listener.
     function fnStartAnimation() {
         stage.addChild(exportRoot, lineShape);