2c33e5b32a7dbc289a9c3b5536d0d3210c7135f3 2.0 KB

1234567
  1. {
  2. "code": "export default class Ball extends Laya.Script {\r\n constructor() {\r\n super();\r\n this.TargetArray = [];\r\n this.clear = false;\r\n Ball.ins = this;\r\n }\r\n static get Instance() {\r\n if (Ball.ins) {\r\n return Ball.ins;\r\n }\r\n else {\r\n return new Ball();\r\n }\r\n }\r\n onAwake() {\r\n }\r\n onEnable() {\r\n this.TargetArray = [];\r\n this.owner.on(Laya.Event.CLICK, this, this.TweenMerge);\r\n }\r\n onUpdate() {\r\n }\r\n onDestroy() {\r\n }\r\n onTriggerEnter(other) {\r\n }\r\n onTriggerStay(other) {\r\n let targetparent = other.owner;\r\n this.TargetArray.push(targetparent);\r\n }\r\n onTriggerExit(other) {\r\n let targetparent = other.owner;\r\n }\r\n Move(_position) {\r\n let owner = this.owner;\r\n let move = Laya.Tween.to(this.owner, {\r\n x: _position.x, y: _position.y, update: new Laya.Handler(this, function () {\r\n })\r\n }, 300, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {\r\n move.clear();\r\n }));\r\n }\r\n TweenMerge() {\r\n if (this.TargetArray.length <= 0) {\r\n console.log(\"周围什么没有--\");\r\n return;\r\n }\r\n let clickscore = this.owner.getChildByName(\"num\");\r\n console.log(\"点到了\", clickscore.value);\r\n for (let i = 0; i < this.TargetArray.length; i++) {\r\n if (this.TargetArray[i].name == \"RightCollider\" || this.TargetArray[i].name == \"LeftCollider\" || this.TargetArray[i].name == \"BottomCollider\") {\r\n console.log(\"周围有墙壁-- \");\r\n continue;\r\n }\r\n let score = this.TargetArray[i].getChildByName(\"num\");\r\n console.log(\"周围有--\", score.value);\r\n }\r\n }\r\n}\r\n",
  3. "references": [
  4. "E:/LayaProject/BlastToMerge/src/Tool/GameTools.ts"
  5. ]
  6. }