SGLBItem.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. var Global = require("Global");
  2. var GameProtocol = require("SGLBGameProtocol");
  3. cc.Class({
  4. extends: cc.Component,
  5. editor: {
  6. menu: 'Game/SGLB/Item'
  7. },
  8. properties: {
  9. normalBG: cc.Node,
  10. normalAni: sp.Skeleton,
  11. aniNode: cc.Node,
  12. _value: -1,
  13. _lineCount: 0,
  14. _bFree: false,
  15. },
  16. // LIFE-CYCLE CALLBACKS:
  17. // onLoad () {},
  18. setValue (_val, spineData) {
  19. this._value = _val;
  20. this._bFree = (_val == GameProtocol.FREE_ICON);
  21. this.normalAni.skeletonData = spineData;
  22. this.showNormal();
  23. },
  24. resetCount() {
  25. this._lineCount = 0;
  26. this.showNormal();
  27. },
  28. addCount() {
  29. this._lineCount++;
  30. },
  31. showNormal() {
  32. this.normalBG.stopAllActions();
  33. this.normalBG.scale = 1;
  34. this.aniNode.active = false;
  35. this.normalAni.clearTracks();
  36. this.normalAni.setAnimation(0, "a1", false);
  37. },
  38. showSpecial() {
  39. },
  40. showLightAni() {
  41. if(this._lineCount <= 0) {
  42. this.showNormal();
  43. return;
  44. }
  45. this.aniNode.active = true;
  46. this.normalBG.stopAllActions();
  47. this.normalAni.clearTracks();
  48. this.normalAni.setAnimation(0, "a2", false);
  49. // cc.tween(this.normalBG)
  50. // .sequence(
  51. // cc.tween().to(0.25, {scale: 1.1}),
  52. // cc.tween().to(0.25, {scale: 1.0})
  53. // )
  54. // .repeatForever()
  55. // .start()
  56. },
  57. showLightAniNoScale() {
  58. if(this._lineCount <= 0) {
  59. this.showNormal();
  60. return;
  61. }
  62. this.aniNode.active = true;
  63. this.normalBG.stopAllActions();
  64. },
  65. showSpecialAni() {
  66. if(!this._bFree) {
  67. // this.showNormal();
  68. return;
  69. }
  70. this.normalBG.stopAllActions();
  71. this.normalAni.clearTracks();
  72. this.normalAni.setAnimation(0, "a2", false);
  73. // cc.tween(this.normalBG)
  74. // .sequence(
  75. // cc.tween().to(0.25, {scale: 1.1}),
  76. // cc.tween().to(0.25, {scale: 1.0})
  77. // )
  78. // .repeatForever()
  79. // .start()
  80. },
  81. // update (dt) {},
  82. });