Shade.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. FadeTag : null
  5. },
  6. start () {
  7. this.node.setLocalZOrder(999999);
  8. this.FadeTag = false;
  9. },
  10. onload : function () {
  11. },
  12. FadeInAndOut:function(callbackFadeIn,callbackFadeOut)
  13. {
  14. cc.log("准备黑屏",this.FadeTag);
  15. if (this.FadeTag) {
  16. return;
  17. }
  18. this.node.opacity=0;
  19. // this.FadeOut(10,function () {
  20. //
  21. // }.bind(this));
  22. this.FadeTag = true;
  23. this.FadeIn(3,function () {
  24. if (callbackFadeIn != null) {
  25. callbackFadeIn();
  26. }
  27. setTimeout(function () {
  28. this.FadeOut(3,function () {
  29. if (callbackFadeOut != null) {
  30. callbackFadeOut();
  31. this.FadeTag = false;
  32. }
  33. }.bind(this));
  34. }.bind(this),300);
  35. }.bind(this));
  36. // this.FadeTag = true;
  37. },
  38. // FadeInAndOutControl : function (tag) {
  39. // if (tag) {
  40. // this.node.opacity+=4;
  41. // }else {
  42. //
  43. // }
  44. // },
  45. FadeIn:function(duration,fun)
  46. {
  47. var rate = duration/255;
  48. this.schedule(function()
  49. {
  50. if(this.node.opacity>=250)
  51. {
  52. if(this.node.opacity==255)
  53. {
  54. if(fun!=null)
  55. {
  56. fun();
  57. }
  58. }
  59. this.node.opacity =255;
  60. return;
  61. }
  62. this.node.opacity +=5;
  63. }, rate,51);
  64. },
  65. FadeOut:function(duration,fun)
  66. {
  67. var rate = duration/255;
  68. this.schedule(function()
  69. {
  70. if(this.node.opacity<=5)
  71. {
  72. if(this.node.opacity==0)
  73. {
  74. if(fun!=null)
  75. {
  76. this.node.opacity =0;
  77. fun();
  78. }
  79. }
  80. this.node.opacity =0;
  81. return;
  82. }
  83. this.node.opacity -=5;
  84. }, rate,51);
  85. },
  86. FadeInCallBack:function()
  87. {
  88. },
  89. FadeOutCallBack:function()
  90. {
  91. },
  92. // update :function(dt) {
  93. // // if (this.FadeTag != null) {
  94. // // this.FadeInAndOutControl(this.FadeTag);
  95. // // }
  96. //
  97. // },
  98. });