zenghaowei 3 лет назад
Родитель
Сommit
c876102280

+ 86 - 0
assets/Script/game/element/JG0115.ts

@@ -0,0 +1,86 @@
+import BaseEvent from "../fight/evnet/base/BaseEvent";
+import { SpriteActionType } from "../fight/object/FSprite";
+
+const { ccclass, property } = cc._decorator;
+
+// 加速带方向
+export enum SpeedUpDirection {
+    Left = "zuo",
+    Right = "you",
+    Up = "shang",
+    Down = "xia",
+}
+
+@ccclass
+export default class NewClass extends BaseEvent {
+
+    @property({
+        type: sp.Skeleton,
+        displayName: "动画"
+    })
+    spine: sp.Skeleton = null;
+
+    @property({
+        displayName: "方向",
+    })
+    speedUpDirection: SpeedUpDirection = SpeedUpDirection.Left;
+
+    @property({
+        displayName: "加速时间",
+    })
+    speedUpTime: number = 0.5;
+
+    @property({
+        displayName: "加速倍数",
+    })
+    speedUpMul: number = 2;
+
+    @property({
+        displayName: "加速距离",
+    })
+    speedUpDis: number = 320;
+
+    onLoad() {
+        super.onLoad();
+        this.node.zIndex = -9999;
+        this.spine.setAnimation(0, this.speedUpDirection, true);
+    }
+
+    onBegin() {
+        // this.ff.mainSprite.setSpeedUpInfo(this.direction, this.speedUpTime, this.speedUpMul);
+        this.ff.mainSprite.speedUp = this.speedUpDirection;
+        let sprite = this.ff.mainSprite;
+        let moveX = 1;
+        let moveY = 0;
+        let scaleX = 1;
+        if (this.speedUpDirection == SpeedUpDirection.Left) {
+            moveX = -1;
+            moveY = 0;
+            scaleX = -1;
+        } else if (this.speedUpDirection == SpeedUpDirection.Right) {
+            moveX = 1;
+            moveY = 0;
+        } else if (this.speedUpDirection == SpeedUpDirection.Up) {
+            moveX = 0;
+            moveY = 1;
+        } else if (this.speedUpDirection == SpeedUpDirection.Down) {
+            moveX = 0;
+            moveY = -1;
+        }
+        if (this.speedUpDirection == SpeedUpDirection.Left) {
+            sprite.node.scaleX = -Math.abs(sprite.node.scaleX);
+        } else {
+            sprite.node.scaleX = Math.abs(sprite.node.scaleX);
+        }
+        sprite.spine.setAnimation(0, SpriteActionType.move, true);
+        cc.tween(sprite.node).sequence(
+            cc.moveTo(this.speedUpTime, cc.v2(sprite.node.x + this.speedUpDis * moveX, sprite.node.y + this.speedUpDis * moveY)),
+            cc.callFunc(() => {
+                if (!sprite.isWalk) {
+                    sprite.spine.setAnimation(0, SpriteActionType.stand, true);
+                }
+                this.ff.mainSprite.speedUp = "";
+            })
+        ).start();
+    }
+}

+ 9 - 0
assets/Script/game/element/JG0115.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "e9d7b817-c8af-4e68-b644-63246dc8f4cd",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 19 - 7
assets/Script/game/fight/object/MSprite.ts

@@ -1,8 +1,8 @@
 
 import Joystick_mag, { SpeedType } from "../../../joystick/Joystick_mag";
-import Joystick from "../../../util/Joystick";
 import { FFAttr } from "../../data/FFCalAttr";
 import { __SkillData } from "../../data/sdata/SManage";
+import { SpeedUpDirection } from "../../element/JG0115";
 import BObject from "../bullet/BObject";
 import FSprite, { SpriteActionType } from "./FSprite";
 import MBomb from "./skill/mainSkill/MBomb";
@@ -36,8 +36,9 @@ export default class MSprite extends FSprite {
      * 移动速度
      */
     private speedN = 120000;
+    public speedUp: string = "";
 
-    public start(){
+    public start() {
         super.start()
         this.spineEventListener()
     }
@@ -96,6 +97,7 @@ export default class MSprite extends FSprite {
         if (this.gamePause) {
             return;
         }
+        if (this.speedUp != "") return
         if (this.isWalk) {
             this.mRigidBody.applyLinearImpulse(
                 cc.v2(this.moveV2.x * this.speedN * dt, this.moveV2.y * this.speedN * dt),
@@ -117,14 +119,14 @@ export default class MSprite extends FSprite {
         this.moveV2 = v2;
         //有怪物的时候,面向怪物
         let enemy = this.findEnemy(2000);
-        if(enemy.sprite){
+        if (enemy.sprite) {
             let abs = Math.abs(this.spine.node.scaleX);
-            if(this.node.x > enemy.sprite.node.x){
+            if (this.node.x > enemy.sprite.node.x) {
                 this.spine.node.scaleX = -abs;
-            }else{
+            } else {
                 this.spine.node.scaleX = abs;
             }
-        }else{
+        } else {
             let abs = Math.abs(this.spine.node.scaleX);
             if (v2.x <= 0.001 && v2.x >= -0.001) {
             } else if (v2.x > 0) {
@@ -132,6 +134,16 @@ export default class MSprite extends FSprite {
             } else {
                 this.spine.node.scaleX = -abs;
             }
+
+            if (this.speedUp != "") {
+                if (this.speedUp == SpeedUpDirection.Left) {
+                    this.spine.node.scaleX = -Math.abs(this.spine.node.scaleX);
+                } else {
+                    this.spine.node.scaleX = Math.abs(this.spine.node.scaleX);
+                }
+            }
+
+
         }
     }
 
@@ -227,7 +239,7 @@ export default class MSprite extends FSprite {
      */
     private endShooting() {
         this.currentShooting = false;
-        if(this.mWeapon1){
+        if (this.mWeapon1) {
             this.mWeapon1.rotation = 180;
         }
         if (this.isWalk) {

+ 4 - 4
assets/resources/prefab/element/JG0115.prefab

@@ -55,15 +55,15 @@
       "__type__": "TypedArray",
       "ctor": "Float64Array",
       "array": [
-        0,
-        0,
+        483.236,
+        2272.822,
         0,
         0,
         0,
         0,
         1,
-        4,
-        4,
+        2,
+        2,
         4
       ]
     },