monsterPlay.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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.play();
  18. });
  19. this.getComponentsInChildren(AniList).forEach(v=>{
  20. v.play();
  21. });
  22. }
  23. protected onLostFocusInEditor(): void {
  24. let arr = this.getComponentsInChildren(MonsterFactory);
  25. arr.forEach(v=>{
  26. v.end();
  27. });
  28. this.getComponentsInChildren(AniList).forEach(v=>{
  29. v.end();
  30. });
  31. }
  32. }