import ResManager from "./ResManager"; import ParticleEffect from "../ParticleEffect"; import Common from "../common/Common"; // Learn TypeScript: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html // Learn Attribute: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html const {ccclass} = cc._decorator; @ccclass export default class ParticleEffectManager extends cc.Component { private static instance:ParticleEffectManager = null; public static getInstance():ParticleEffectManager{ if(this.instance == null){ this.instance = new ParticleEffectManager(); } return this.instance; } //创建粒子效果 public showParticleEffect(effecid,pos:cc.Vec2,playTime:number = 1,showColor:cc.Color = null,effectRoot:cc.Node = null):ParticleEffect{ let effectObj = cc.instantiate( Common.nodeParticleEffects.children[effecid]) if(effectRoot != null){ effectRoot.addChild(effectObj); }else{ Common.nodeBallRoot.addChild(effectObj); } let effect:ParticleEffect = effectObj.addComponent(ParticleEffect); effect.setInfo(pos,playTime,showColor); return effect; } }