瀏覽代碼

地刺碰撞回弹

chelios 3 年之前
父節點
當前提交
d6ce7a8678
共有 2 個文件被更改,包括 27 次插入6 次删除
  1. 23 0
      assets/Script/game/element/JG0108_1.ts
  2. 4 6
      assets/resources/prefab/map/map2.prefab

+ 23 - 0
assets/Script/game/element/JG0108_1.ts

@@ -9,12 +9,30 @@ const { ccclass, property } = cc._decorator;
 @ccclass
 export default class JG0108_1 extends BaseEvent {
 
+    @property({
+        displayName: '数值(怪物id)'
+    })
+    public monsterId = 1001;
+
     /**
      * 主角进入碰撞区域
      *  @param tag 碰撞组件编号
      */
     public onBegin(tag: number) {
+        let moveV2 = this.ff.mainSprite.moveV2
+        this.ff.mainSprite.setPause(true)
 
+        let des = 30;
+        let x = -des*moveV2.x
+        let y = -des*moveV2.y
+        this.rmHP()
+        cc.tween(this.ff.mainSprite.node).sequence(
+            cc.moveBy(0.5,cc.v2(x,y)).easing(cc.easeBackOut()),
+            cc.delayTime(0.5),
+            cc.callFunc(()=>{
+                this.ff.mainSprite.setPause(false)
+            })
+        ).start()
     }
     /**
      * 主角离开碰撞区域
@@ -23,4 +41,9 @@ export default class JG0108_1 extends BaseEvent {
     public onEnd(tag: number) {
 
     }
+    private rmHP() {
+        let main = this.ff.main;
+        let attrData = main.sManage.getMonsterData(this.monsterId);
+        this.ff.mainSprite.bAtkjs(attrData);
+    }
 }

+ 4 - 6
assets/resources/prefab/map/map2.prefab

@@ -687,7 +687,7 @@
     "node": {
       "__id__": 16
     },
-    "_enabled": false,
+    "_enabled": true,
     "_materials": [
       {
         "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
@@ -27712,7 +27712,7 @@
     "_id": ""
   },
   {
-    "__type__": "aa2069eQnZKQ5bx1gW1UbwJ",
+    "__type__": "e6226sswJlNpYr5//vvyEFJ",
     "_name": "",
     "_objFlags": 0,
     "node": {
@@ -27720,8 +27720,6 @@
     },
     "_enabled": true,
     "monsterId": 1001,
-    "interval": 0,
-    "spine": null,
     "_id": ""
   },
   {
@@ -29347,8 +29345,8 @@
       "__type__": "TypedArray",
       "ctor": "Float64Array",
       "array": [
-        873.893,
-        5919.384,
+        4145.916,
+        4043.649,
         0,
         0,
         0,