123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import FSprite from "../object/FSprite";
- import FObject from "../object/FObject";
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class GEffect extends cc.Component {
- @property({
- displayName: '最大攻击人数'
- })
- maxCount: number = 1;
-
- public sprite:FSprite;
- private hitCount = 0;
-
- start () {
- this.hitCount = 0;
- let armature = this.node.getComponent(dragonBones.ArmatureDisplay);
- armature.addEventListener(dragonBones.EventObject.LOOP_COMPLETE as any ,(event)=>{
- this.node.destroy();
- }, this);
- }
- onBeginContact(contact: cc.PhysicsContact, selfCollider: cc.PhysicsCollider, otherCollider: cc.PhysicsCollider){
- if(this.hitCount >= this.maxCount){
- return;
- }
- if(this.sprite.node.group != otherCollider.node.group){
- let target = otherCollider.node.getComponent(FSprite);
- if(target){
- this.hitCount ++;
- this.sprite.atkjs(target);
- }
- }
- }
- }
|