import FF from "../../FF"; import { GroupType } from "../../object/FObject"; import FSprite from "../../object/FSprite"; /** * 警示区域碰撞逻辑处理 */ const {ccclass, property} = cc._decorator; @ccclass export default class FPatrolWarn extends cc.Component { @property(cc.Node) mInitPos: cc.Node = null; public ff:FF; private isOver = false; onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider){ if(this.isOver){ return; } if(other.node.group == 'A'){ let obj = other.node.getComponent(FSprite); this.ff = obj.ff; this.isOver = true; this.ff.pauseSprite(true); cc.tween(this).sequence( cc.delayTime(0.01), cc.callFunc(()=>{ let pos = this.mInitPos.getPosition(); let sprites = this.ff.getGroupBy(GroupType.A); for (let i = 0; i < sprites.length; i++) { const element = sprites[i]; if(element){ element.setPosition(pos); } } }), cc.delayTime(0.01), cc.callFunc(()=>{ this.isOver = false; this.ff.pauseSprite(false); }), ).start(); } } }