Shade.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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("我是shade的FadeInAndOut,我的FadeTag是"+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(0.1,function () {
  24. if (callbackFadeIn != null) {
  25. callbackFadeIn();
  26. }else{
  27. }
  28. setTimeout(function () {
  29. this.FadeOut(0.1,function () {
  30. this.FadeTag = false;
  31. if (callbackFadeOut != null) {
  32. callbackFadeOut();
  33. // cc.find("TouchLayout").getComponent("NodeTouch").touchClick(true);
  34. // cc.eventManager.resumeTarget(cc.find("TouchLayout"),true)
  35. }
  36. }.bind(this));
  37. }.bind(this),500);
  38. }.bind(this));
  39. // this.FadeTag = true;
  40. },
  41. // FadeInAndOutControl : function (tag) {
  42. // if (tag) {
  43. // this.node.opacity+=4;
  44. // }else {
  45. //
  46. // }
  47. // },
  48. FadeIn:function(duration,fun)
  49. {
  50. var rate = duration/255;
  51. this.schedule(function()
  52. {
  53. if(this.node.opacity>=250)
  54. {
  55. if(this.node.opacity==255)
  56. {
  57. if(fun!=null)
  58. {
  59. fun();
  60. }
  61. }
  62. this.node.opacity =255;
  63. return;
  64. }
  65. this.node.opacity +=5;
  66. }, rate,51);
  67. },
  68. FadeOut:function(duration,fun)
  69. {
  70. var rate = duration/255;
  71. this.schedule(function()
  72. {
  73. if(this.node.opacity<=5)
  74. {
  75. if(this.node.opacity==0)
  76. {
  77. if(fun!=null)
  78. {
  79. this.node.opacity =0;
  80. fun();
  81. }
  82. }
  83. this.node.opacity =0;
  84. return;
  85. }
  86. this.node.opacity -=5;
  87. }, rate,51);
  88. },
  89. FadeInCallBack:function()
  90. {
  91. },
  92. FadeOutCallBack:function()
  93. {
  94. },
  95. update :function(dt) {
  96. // cc.log(this.FadeTag+'******');
  97. // if (this.FadeTag != null) {
  98. // this.FadeInAndOutControl(this.FadeTag);
  99. // }
  100. },
  101. });