Browse Source

推箱子优化

chelios 3 years ago
parent
commit
ab8ec81208

+ 17 - 20
assets/Script/game/element/JG0111.ts

@@ -62,8 +62,6 @@ export default class JG0111 extends BaseEvent {
      */
     public isOver = false;
 
-    private count = 0;
-
     onLoad(){
         super.onLoad();
         this.node.zIndex = -9999;
@@ -71,37 +69,36 @@ export default class JG0111 extends BaseEvent {
 
     onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider) {
         if (other.node.group != 'bullet') {
-            this.count++
-            this.onBegin(self.tag)
+            this.onBegin(other.tag)
         }
 
     }
 
     onEndContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider) {
         if (other.node.group != 'bullet') {
-            this.count--
-            if (this.count <= 0) {
-                this.count = 0;
-                this.onEnd(self.tag)
-            }
+            this.onEnd(other.tag)
         }
     }
 
     onBegin(tag: number) {
-        this.isHang = true;
-        this.mIcon.spriteFrame = this.mIcon1;
-        this.checkOpen();
+        if(tag == 1){
+            this.isHang = true;
+            this.mIcon.spriteFrame = this.mIcon1;
+            this.checkOpen();
+        }
     }
 
     onEnd(tag: number) {
-        this.isHang = false
-        this.mIcon.spriteFrame = this.mIcon0
-        this.isOver = false;
-        for (let i = 0; i < this.mFenceTrigger.length; i++) {
-            const element = this.mFenceTrigger[i];
-            // element.active = true;
-            this.showFence(element, SpineName.CLOSE);
-            element.getComponent(cc.PhysicsBoxCollider).enabled = true;
+        if(tag == 1){
+            this.isHang = false
+            this.mIcon.spriteFrame = this.mIcon0
+            this.isOver = false;
+            for (let i = 0; i < this.mFenceTrigger.length; i++) {
+                const element = this.mFenceTrigger[i];
+                // element.active = true;
+                this.showFence(element, SpineName.CLOSE);
+                element.getComponent(cc.PhysicsBoxCollider).enabled = true;
+            }
         }
     }
 

+ 1 - 1
assets/resources/prefab/element/JG0109.prefab

@@ -144,7 +144,7 @@
       "__id__": 1
     },
     "_enabled": true,
-    "tag": 0,
+    "tag": 1,
     "_density": 8,
     "_sensor": false,
     "_friction": 0,

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

@@ -155,13 +155,13 @@
     "body": null,
     "_offset": {
       "__type__": "cc.Vec2",
-      "x": 0,
-      "y": 0
+      "x": -0.76,
+      "y": 5.13
     },
     "_size": {
       "__type__": "cc.Size",
-      "width": 20,
-      "height": 20
+      "width": 9.91,
+      "height": 9.73
     },
     "_id": ""
   },

+ 12 - 12
assets/resources/prefab/map/map1.prefab

@@ -5759,13 +5759,13 @@
     "body": null,
     "_offset": {
       "__type__": "cc.Vec2",
-      "x": 0,
-      "y": 0
+      "x": -0.3,
+      "y": 5.1
     },
     "_size": {
       "__type__": "cc.Size",
-      "width": 20,
-      "height": 20
+      "width": 10.3,
+      "height": 10
     },
     "_id": ""
   },
@@ -10347,13 +10347,13 @@
     "body": null,
     "_offset": {
       "__type__": "cc.Vec2",
-      "x": 0,
-      "y": 0
+      "x": -0.6,
+      "y": 5.2
     },
     "_size": {
       "__type__": "cc.Size",
-      "width": 20,
-      "height": 20
+      "width": 11.2,
+      "height": 9.7
     },
     "_id": ""
   },
@@ -35620,7 +35620,7 @@
       "__id__": 1027
     },
     "_enabled": true,
-    "tag": 0,
+    "tag": 1,
     "_density": 8,
     "_sensor": false,
     "_friction": 0,
@@ -35784,7 +35784,7 @@
       "__id__": 1032
     },
     "_enabled": true,
-    "tag": 0,
+    "tag": 1,
     "_density": 8,
     "_sensor": false,
     "_friction": 0,
@@ -37445,8 +37445,8 @@
       "__type__": "TypedArray",
       "ctor": "Float64Array",
       "array": [
-        461.281,
-        2534.018,
+        3524.551,
+        1856.622,
         0,
         0,
         0,