NodeAct.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //调整铺满屏幕
  2. function FitSize(node) {
  3. // return;
  4. // if(cc.sys.isNative){
  5. // cc.view.setDesignResolutionSize(window.SCENE_WIGHT, window.SCENE_HEIGHT, cc.ResolutionPolicy.EXACT_FIT);
  6. // }else{
  7. // var nWp = 0, nHp = 0;
  8. // nWp = document.body.clientWidth / window.SCENE_WIGHT;
  9. // nHp = document.body.clientHeight / window.SCENE_HEIGHT;
  10. // cc.view.setDesignResolutionSize(document.body.clientWidth, document.body.clientHeight, cc.ResolutionPolicy.EXACT_FIT);
  11. // node.setScale(nWp, nHp);
  12. // }
  13. // let c = node.getComponent(cc.Canvas);
  14. // if(c == undefined || c == null){
  15. // return;
  16. // }
  17. // c.fitHeight = true;
  18. // c.fitWidth = false;
  19. // node.setScale(cc.winSize.width / window.SCENE_WIGHT, 1);
  20. }
  21. //Left to Center
  22. function ShowL2C(ActNode) {
  23. ActNode.active = true;
  24. ActNode.stopAllActions();
  25. ActNode.setPosition(-window.SCENE_WIGHT,0);
  26. ActNode.runAction( cc.moveTo(0.5,cc.v2(0,0)).easing(cc.easeBounceOut()) );
  27. }
  28. //Center to Left
  29. function HideC2L(ActNode, CallBack) {
  30. ActNode.runAction( cc.sequence( cc.moveTo(0.1,cc.v2(-window.SCENE_WIGHT,0)), cc.callFunc(function(){
  31. if(CallBack){
  32. CallBack();
  33. }else{
  34. ActNode.active = false;
  35. }
  36. }) ) );
  37. }
  38. //Left to Center
  39. function ShowR2C(ActNode, dt) {
  40. ActNode.active = true;
  41. ActNode.stopAllActions();
  42. ActNode.setPosition(window.SCENE_WIGHT,0);
  43. ActNode.runAction(cc.moveTo(dt ? dt : 0.1,cc.v2(0,0)));
  44. }
  45. //Center to Left
  46. function HideC2R(ActNode, CallBack) {
  47. ActNode.runAction( cc.sequence( cc.moveTo(0.1,cc.v2(window.SCENE_WIGHT,0)), cc.callFunc(function(){
  48. if(CallBack){
  49. CallBack();
  50. }else{
  51. ActNode.active = false;
  52. }
  53. }) ) );
  54. }
  55. //Small to Normal
  56. function ShowS2N(ActNode, dt, dt2) {
  57. ActNode.active = true;
  58. ActNode.stopAllActions();
  59. ActNode.setScale(0);
  60. ActNode.opacity = 0;
  61. var act = cc.scaleTo(dt ? dt : 0.5, 1, 1).easing(cc.easeBounceOut());
  62. ActNode.runAction( cc.spawn(act, cc.fadeIn(dt2 ? dt2 : 0.3)) );
  63. //ActNode.runAction( act );
  64. }
  65. //Small to Normal
  66. function ShowS2N2(ActNode, bBounce, dt, dt2) {
  67. ActNode.active = true;
  68. ActNode.stopAllActions();
  69. ActNode.setScale(0);
  70. ActNode.opacity = 0;
  71. var act = null;
  72. if(bBounce) act = cc.scaleTo(dt ? dt : 0.5, 1, 1).easing(cc.easeBounceOut());
  73. else act = cc.scaleTo(dt ? dt : 0.5, 1, 1);
  74. ActNode.runAction( cc.spawn(act, cc.fadeIn(dt2 ? dt2 : 0.3)) );
  75. //ActNode.runAction( act );
  76. }
  77. //Normal to Small
  78. function HideN2S(ActNode, CallBack) {
  79. //ActNode.runAction( cc.sequence( cc.scaleTo(0.1, 0, 0), cc.callFunc(CallBack) ) );
  80. ActNode.runAction( cc.sequence( cc.scaleTo(0.1, 0, 0), cc.callFunc(function(){
  81. ActNode.active = false;
  82. } ) ) );
  83. }
  84. // Show Out to In
  85. function ShowO2I(ActNode, dt) {
  86. ActNode.active = true;
  87. ActNode.stopAllActions();
  88. ActNode.opacity = 0;
  89. ActNode.runAction(cc.fadeIn(dt? dt : 0.1));
  90. }
  91. // Hide In to Out
  92. function HideI2O(ActNode, CallBack, dt, bActive) {
  93. ActNode.runAction( cc.sequence( cc.fadeOut(dt? dt : 0.1), cc.callFunc(function() {
  94. if(CallBack) CallBack();
  95. ActNode.active = bActive ? true : false;
  96. } ) ) );
  97. }
  98. // 上漂后销毁
  99. function FlyDestroy(ActNode) {
  100. if (!ActNode) return;
  101. ActNode.active = true;
  102. ActNode.stopAllActions();
  103. ActNode.opacity = 255;
  104. ActNode.setScale(0);
  105. ActNode.runAction(cc.sequence(
  106. cc.spawn(cc.scaleTo(0.5, 1, 1).easing(cc.easeBounceOut()), cc.delayTime(1)),
  107. cc.spawn(cc.fadeOut(1.5), cc.moveBy(1.5, cc.v2(0, 80))),
  108. cc.delayTime(0.5), cc.removeSelf(true)
  109. ));
  110. }