anmove.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. // foo: {
  14. // // ATTRIBUTES:
  15. // default: null, // The default value will be used only when the component attaching
  16. // // to a node for the first time
  17. // type: cc.SpriteFrame, // optional, default is typeof default
  18. // serializable: true, // optional, default is true
  19. // },
  20. // bar: {
  21. // get () {
  22. // return this._bar;
  23. // },
  24. // set (value) {
  25. // this._bar = value;
  26. // }
  27. // },
  28. },
  29. // LIFE-CYCLE CALLBACKS:
  30. // onLoad () {},
  31. start () {
  32. let x = UtilsNode.getRandom(2,2,10);
  33. for (var i = 0; i < this.node.children.length; i++) {
  34. let node = this.node.children[i];
  35. let name = node.name;
  36. let myAction =null;
  37. switch (name) {
  38. case "bg2":
  39. case "bg3":
  40. case "bg5":
  41. case "bg6":
  42. myAction = cc.repeatForever(cc.sequence(cc.moveBy(1, -5,0),cc.moveBy(1, 5,0)));
  43. node.runAction(myAction)
  44. break;
  45. case "bg4":
  46. case "bg1":
  47. myAction = cc.repeatForever(cc.sequence(cc.rotateBy(1, 3),cc.rotateBy(1, -3)));
  48. node.runAction(myAction)
  49. break;
  50. }
  51. }
  52. // let myAction = cc.repeatForever(cc.sequence(cc.rotateBy(1, 5),cc.rotateBy(1, -5)));
  53. // this.node.runAction(myAction)
  54. },
  55. // update (dt) {},
  56. });