zhoupeng 1 سال پیش
والد
کامیت
d63c8e1258

+ 25 - 0
airPlay/assets/Script/game/common/utils.ts

@@ -59,4 +59,29 @@ export namespace Utils {
         let posJson = Utils.strToJson(pos);
         return cc.v2(Number(posJson[0]), -Number(posJson[1]));
     }
+
+    export function getAniExtent(state: cc.AnimationState){
+        // let cur = state.curves;
+
+        let extent = 0;
+
+        for (let index = 0; index < state.curves.length; index++) {
+            const element = state.curves[index];
+            if(element.prop == 'position') {
+                let values = element.values as cc.Vec3[];
+                for (let index = 1; index < values.length; index++) {
+                    extent += values[index].sub(values[index-1]).mag();
+                }
+            }
+
+            if(element.prop == 'y' || element.prop == 'x') {
+                let values = element.values as number[];
+                for (let index = 1; index < values.length; index++) {
+                    extent += Math.abs(values[index] - values[index-1]);
+                }
+            }
+
+        }
+        return extent;
+    }
 }

+ 2 - 2
airPlay/assets/Script/game/nest/barrage.ts

@@ -236,7 +236,7 @@ export class Barrage extends GameSysLogic{
             }, subBulletItem);
 
             bulletNode.destroy();
-            console.log('@@=',bulletNode.getPosition().toString());
+            // console.log('@@=',bulletNode.getPosition().toString());
         }
         let localPos = this.layer.convertToNodeSpaceAR(worldPos);
         bulletNode.setPosition(localPos);
@@ -283,7 +283,7 @@ export class Barrage extends GameSysLogic{
                 // console.log( "@@-", bulletNode1.getPosition().toString());
             }
             bulletNode.destroy();
-            console.log('@@=',bulletNode.getPosition().toString());
+            // console.log('@@=',bulletNode.getPosition().toString());
         }
         let localPos = this.layer.convertToNodeSpaceAR(worldPos);
         bulletNode.setPosition(localPos);

+ 9 - 2
airPlay/assets/Script/game/nest/nestPlay.ts

@@ -202,7 +202,8 @@ export class NestPlay extends cc.Component {
                         // modleNode.setPosition(cc.v2(0,0));
     
                         let ani = aniNode.addComponent(cc.Animation);
-                        ani.addClip(this.aniClip[cnt], 'path')
+                        let state = ani.addClip(this.aniClip[cnt], 'path')
+                        // cc.log('@@ ', state);
                         ani.play('path').speed = 0.3;
                         
                         ani.once(cc.Animation.EventType.FINISHED, ()=>{
@@ -260,8 +261,14 @@ export class NestPlay extends cc.Component {
                     parent.addChild(aniNode);
 
                     let ani = aniNode.addComponent(cc.Animation);
+                    // ani.addClip(this.aniClip[cnt], 'path')
                     ani.addClip(this.aniClip[cnt], 'path')
-                    ani.play('path').speed = 0.3;
+                    
+                    let state = ani.play('path');
+                    let extent = Utils.getAniExtent(state);
+                    let d = state.duration;
+                    state.speed = state.duration / (extent / 200);
+                    // cc.log('@@ ',extent + '|', d, state.duration, state.speed);
                     
                     ani.once(cc.Animation.EventType.FINISHED, ()=>{
                         cnt++;

+ 2 - 2
airPlay/assets/Script/game/player.ts

@@ -80,7 +80,7 @@ export default class Player extends GameLogic {
     canAtk(key: string){
         if(!this.atkRecord.has(key)) return true;
         if(Date.now() - this.atkRecord.get(key) >= 500){
-            cc.log('@@ key', key, ' | ',this.atkRecord.get(key));
+            // cc.log('@@ key', key, ' | ',this.atkRecord.get(key));
             return true;
         }
         return false;
@@ -88,6 +88,6 @@ export default class Player extends GameLogic {
 
     beAtked(key: string){
         this.atkRecord.set(key, Date.now())
-        cc.log('@@ addkey', key, ' | ',this.atkRecord.get(key));
+        // cc.log('@@ addkey', key, ' | ',this.atkRecord.get(key));
     }
 }

+ 1 - 1
airPlay/assets/Script/game/update/moveDest.ts

@@ -44,7 +44,7 @@ export default class MoveDest extends GameLogic {
             this.node.y += this.speed * dt * dirction.y;
         }
 
-        cc.log('@@ -- ', this.node.position.toString());
+        // cc.log('@@ -- ', this.node.position.toString());
         this.node.x = Math.max(-this.x_max , this.node.x);
         this.node.x = Math.min(this.x_max , this.node.x);