FOpenDoorFW.ts 968 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import BaseEvent from "../base/BaseEvent";
  2. /**
  3. * 复位开关
  4. */
  5. const {ccclass, property} = cc._decorator;
  6. @ccclass
  7. export default class FOpenDoorFW extends BaseEvent {
  8. @property({
  9. type:[cc.Node],
  10. displayName:'需要复位的节点'
  11. })
  12. mNodes: Array<cc.Node> = [];
  13. private pos = []
  14. onLoad(){
  15. super.onLoad()
  16. for (let i = 0; i < this.mNodes.length; i++) {
  17. const element = this.mNodes[i];
  18. this.pos.push(element.getPosition())
  19. }
  20. }
  21. onBegin(tag: number) {
  22. for (let i = 0; i < this.mNodes.length; i++) {
  23. const element = this.mNodes[i];
  24. let pos = this.pos[i]
  25. cc.tween(element).sequence(
  26. cc.delayTime(0.1),
  27. cc.callFunc(()=>{
  28. element.x = pos.x
  29. element.y = pos.y
  30. })
  31. ).start()
  32. }
  33. }
  34. onEnd(tag: number) {
  35. }
  36. }