Selaa lähdekoodia

飞icon时后,缩放动画添加

薛鸿潇 5 vuotta sitten
vanhempi
commit
36bbaf05ca
1 muutettua tiedostoa jossa 27 lisäystä ja 7 poistoa
  1. 27 7
      assets/script/mk/system/FlySystem.ts

+ 27 - 7
assets/script/mk/system/FlySystem.ts

@@ -17,7 +17,7 @@ export default class FlySystem extends cc.Component {
      * @param endpos 飞行的目标坐标 或目标对象路径
      * @param endpos 飞行的目标坐标 或目标对象路径
      * @param cb 动画结束回调
      * @param cb 动画结束回调
     */
     */
-    public async PlayCoinAnim(type: number = 0, num: number, pos: cc.Vec2, endpos: cc.Vec2 | string, cb: Function = null) {
+    public async PlayCoinAnim(type: number = 0, num: number, pos: cc.Vec2, endpos: cc.Vec2 | string, item_cb: Function = null) {
         for (let i = 0; i < num; i++) {
         for (let i = 0; i < num; i++) {
             let copyCoin = await mk.pool.getPrefab('game/prefab/coin');
             let copyCoin = await mk.pool.getPrefab('game/prefab/coin');
             let url = 'game/texture/coin/' + type;
             let url = 'game/texture/coin/' + type;
@@ -32,20 +32,20 @@ export default class FlySystem extends cc.Component {
             let initPos = pos.add(deltaInit);
             let initPos = pos.add(deltaInit);
             copyCoin.setPosition(pos);
             copyCoin.setPosition(pos);
 
 
-            this.FlyIn(copyCoin, initPos, endpos, cb);
+            this.FlyIn(type, copyCoin, initPos, endpos, item_cb);
         }
         }
     }
     }
 
 
-    private FlyIn(target: cc.Node, end: cc.Vec2, endpos: cc.Vec2 | string = null, cb: Function = null) {
+    private FlyIn(type: number, target: cc.Node, end: cc.Vec2, endpos: cc.Vec2 | string = null, item_cb: Function = null) {
         cc.tween(target)
         cc.tween(target)
             .to(mk.math.random(0.3, 0.6, false), { position: cc.v3(end) }, cc.easeSineInOut())
             .to(mk.math.random(0.3, 0.6, false), { position: cc.v3(end) }, cc.easeSineInOut())
             .call(() => {
             .call(() => {
-                this.FlyOut(target, endpos, cb);
+                this.FlyOut(type, target, endpos, item_cb);
             })
             })
             .start();
             .start();
     }
     }
 
 
-    private FlyOut(target: cc.Node, end: cc.Vec2 | string, cb: Function = null) {
+    private FlyOut(type: number, target: cc.Node, end: cc.Vec2 | string, item_cb: Function = null) {
         let dur = mk.math.random(0.3, 1, false);
         let dur = mk.math.random(0.3, 1, false);
         cc.tween(target)
         cc.tween(target)
             .to(dur, { scale: 0.8 })
             .to(dur, { scale: 0.8 })
@@ -71,11 +71,31 @@ export default class FlySystem extends cc.Component {
                     cc.tween(end_node).to(0.1, { scale: 1.2 }).to(0.05, { scale: 1 }).start();
                     cc.tween(end_node).to(0.1, { scale: 1.2 }).to(0.05, { scale: 1 }).start();
                 }
                 }
 
 
-                if (cb != null) {
-                    cb();
+                if (item_cb != null) {
+                    item_cb();
+                    this.iconScale(type);
                 }
                 }
             })
             })
             .start();
             .start();
     }
     }
+
+    /**
+     * icon缩放动画
+     * @param type icon类型
+     * @returns 
+     */
+    private iconScale(type: number) {
+        let node;
+        if (type === 1) {
+            node = gData.gameData.gameStyle.icon_hb;
+        } else if (type === 3) {
+            node = gData.gameData.gameStyle.icon_zb;
+        }
+        if (!node) return;
+        let scale1 = cc.tween().to(0.05, { scale: 0.9 });
+        let scale2 = cc.tween().to(0.05, { scale: 1 });
+        let seque = cc.tween().sequence(scale1, scale2);
+        cc.tween(node).then(seque).repeat(2).start();
+    }
 }
 }