monsterPlay.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import AniList from "./aniList";
  8. import MonsterFactory from "./monsterFactory";
  9. const {ccclass, property, executeInEditMode, playOnFocus} = cc._decorator;
  10. @ccclass
  11. @executeInEditMode
  12. @playOnFocus
  13. export default class MonsterPlay extends cc.Component {
  14. protected onFocusInEditor(): void {
  15. let arr = this.getComponentsInChildren(MonsterFactory);
  16. arr.forEach(v=>{
  17. v.end();
  18. v.play();
  19. });
  20. this.getComponentsInChildren(AniList).forEach(v=>{
  21. v.end();
  22. v.play();
  23. });
  24. }
  25. protected onLostFocusInEditor(): void {
  26. let arr = this.getComponentsInChildren(MonsterFactory);
  27. arr.forEach(v=>{
  28. v.end();
  29. });
  30. this.getComponentsInChildren(AniList).forEach(v=>{
  31. v.end();
  32. });
  33. }
  34. }