effectManager.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import itemDtManager from "../dataManager/itemDtManager";
  2. import npcHelper from "../dataManager/npcHelper";
  3. import { AssetsHelper } from "../framework/asset/AssetsHelper";
  4. import { BenzAssetManager } from "../framework/asset/BenzAssetManager";
  5. import Utils from "../framework/utils/utils";
  6. interface offSet {
  7. x: number;
  8. y: number
  9. }
  10. class effectManager {
  11. //播放节点上的特效
  12. public playEff(Node: cc.Node, childName: string, offSet?: offSet, isParticle?: boolean) {
  13. let effNode = Node.getChildByName(childName);
  14. if (isParticle) {
  15. effNode.getComponent(cc.ParticleSystem).resetSystem();
  16. } else {
  17. effNode.getComponent(cc.Animation).play();
  18. }
  19. if (offSet) {
  20. effNode.x += offSet.x;
  21. effNode.y += offSet.y;
  22. }
  23. }
  24. //开火特效
  25. public fireEff(Node: cc.Node, childName: string, offSet?: offSet) {
  26. let fireEffNode = Node.getChildByName('fire1')
  27. fireEffNode.getComponent(cc.Animation).play();
  28. }
  29. //近战攻击
  30. public closeAttack(Node: cc.Node, offSet?: offSet, isParticle?: boolean) {
  31. let anim = Node.getChildByName('closeAttack')
  32. if (isParticle) {
  33. anim.getComponent(cc.Animation).play();
  34. }
  35. anim.getComponent(cc.Animation).play();
  36. if (offSet) {
  37. anim.x += offSet.x;
  38. anim.y += offSet.y;
  39. }
  40. }
  41. public zombieDieEff(parent, Pos) {
  42. // if (cc.sys.platform == cc.sys.WECHAT_GAME) {
  43. // let Eff = BenzAssetManager.getInstance().getAsset(AssetsHelper.EFF_ZOMBIEDIE);
  44. // let Prefb = cc.instantiate(Eff);
  45. // Prefb.parent = parent;
  46. // Prefb.setPosition(Pos);
  47. // setTimeout(() => {
  48. // if (Prefb && Prefb.isValid) {
  49. // Prefb.destroy();
  50. // }
  51. // }, 10000);
  52. // }
  53. }
  54. }
  55. export default new effectManager();