lvupcarAnim.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. const {ccclass, property} = cc._decorator;
  8. @ccclass
  9. export default class lvupcarAnim extends cc.Component {
  10. @property([cc.Node])
  11. nodeList: cc.Node[] = [];
  12. // LIFE-CYCLE CALLBACKS:
  13. // onLoad () {}
  14. start () {
  15. this.schedule(()=>{
  16. if(this.nodeList && cc.isValid(this.nodeList[0]) && cc.isValid(this.nodeList[0]) && cc.isValid(this.nodeList[0])){
  17. let pos0 = this.nodeList[0].x
  18. let pos1 = this.nodeList[1].x
  19. let pos2 = this.nodeList[2].x
  20. this.nodeList[0].x = pos1
  21. this.nodeList[1].x = pos2
  22. this.nodeList[2].x = pos0
  23. }
  24. },0.2)
  25. }
  26. // update (dt) {}
  27. }