CStadium.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. function CStadium( oStadiumContainer){
  2. var _oAudioToggle;
  3. var _oButExit;
  4. var _oStadiumContainer = oStadiumContainer;
  5. var _bUpdate;
  6. var _iArea;
  7. var _oAreaBottom;
  8. var _oAreaTop;
  9. var _oCrowdLeft;
  10. var _oCrowdRight;
  11. var _oBall;
  12. this._init = function(){
  13. var oBg = createBitmap(s_oSpriteLibrary.getSprite('air_view'));
  14. oStadiumContainer.addChild(oBg);
  15. _oAreaBottom = createBitmap(s_oSpriteLibrary.getSprite('area_bottom'));
  16. _oAreaBottom.y = CANVAS_HEIGHT/2;
  17. _oAreaBottom.alpha = 0.5;
  18. oStadiumContainer.addChild(_oAreaBottom);
  19. _oAreaTop = createBitmap(s_oSpriteLibrary.getSprite('area_top'));
  20. _oAreaTop.y = CANVAS_HEIGHT/2-55;
  21. _oAreaTop.alpha = 0.5;
  22. oStadiumContainer.addChild(_oAreaTop);
  23. _oCrowdLeft = createBitmap(s_oSpriteLibrary.getSprite('crowd_left'));
  24. _oCrowdLeft.x = CANVAS_WIDTH/2+56;
  25. _oCrowdLeft.y = CANVAS_HEIGHT/2-150;
  26. _oCrowdLeft.alpha = 0.5;
  27. oStadiumContainer.addChild(_oCrowdLeft);
  28. _oCrowdRight = createBitmap(s_oSpriteLibrary.getSprite('crowd_right'));
  29. _oCrowdRight.y = CANVAS_HEIGHT/2-150;
  30. _oCrowdRight.alpha = 0.5;
  31. oStadiumContainer.addChild(_oCrowdRight);
  32. _oStadiumContainer.visible = false;
  33. _bUpdate = false;
  34. };
  35. this.viewAndGetScore = function(oHitValue, pEndPoint){
  36. var iX = pEndPoint.x;
  37. var pEndPointBounce = {x: 0, y: 0};
  38. var pStartPoint = {x: START_POINT_STADIUM_X, y: START_POINT_STADIUM_Y};
  39. switch(iX){
  40. case END_POINT_X_ALMOST_MINUS_LEFT:
  41. if(oHitValue < (OFFSET_FOR_HIT/2)){
  42. _iArea = 1;
  43. pEndPoint.y = _oAreaTop.y + 30;
  44. pEndPointBounce.x = pEndPoint.x - 10;
  45. pEndPointBounce.y = pEndPoint.y - 10;
  46. }else if(oHitValue < OFFSET_FOR_HIT && oHitValue >= (OFFSET_FOR_HIT/2)){
  47. _iArea = 0;
  48. pEndPoint.y = _oAreaBottom.y + 30;
  49. pEndPointBounce.x = pEndPoint.x - 10;
  50. pEndPointBounce.y = pEndPoint.y - 10;
  51. }
  52. break;
  53. case END_POINT_X_ALMOST_MINUS_RIGHT:
  54. if(oHitValue < (OFFSET_FOR_HIT/2)){
  55. _iArea = 1;
  56. pEndPoint.y = _oAreaTop.y + 30;
  57. pEndPointBounce.x = pEndPoint.x + 10;
  58. pEndPointBounce.y = pEndPoint.y - 10;
  59. }else if(oHitValue < OFFSET_FOR_HIT && oHitValue >= (OFFSET_FOR_HIT/2)){
  60. _iArea = 0;
  61. pEndPoint.y = _oAreaBottom.y + 30;
  62. pEndPointBounce.x = pEndPoint.x + 10;
  63. pEndPointBounce.y = pEndPoint.y - 10;
  64. }
  65. break;
  66. case END_POINT_X_ALMOST_PLUS_LEFT:
  67. if(oHitValue < (OFFSET_FOR_HIT/2)){
  68. _iArea = 1;
  69. pEndPoint.y = _oAreaTop.y + 30;
  70. pEndPointBounce.x = pEndPoint.x - 10;
  71. pEndPointBounce.y = pEndPoint.y - 10;
  72. }else if(oHitValue < OFFSET_FOR_HIT && oHitValue >= (OFFSET_FOR_HIT/2)){
  73. _iArea = 0;
  74. pEndPoint.y = _oAreaBottom.y + 40;
  75. pEndPointBounce.x = pEndPoint.x - 10;
  76. pEndPointBounce.y = pEndPoint.y - 10;
  77. }
  78. break;
  79. case END_POINT_X_ALMOST_PLUS_RIGHT:
  80. if(oHitValue < (OFFSET_FOR_HIT/2)){
  81. _iArea = 1;
  82. pEndPoint.y = _oAreaTop.y + 30;
  83. pEndPointBounce.x = pEndPoint.x + 10;
  84. pEndPointBounce.y = pEndPoint.y - 10;
  85. }else if(oHitValue < OFFSET_FOR_HIT && oHitValue >= (OFFSET_FOR_HIT/2)){
  86. _iArea = 0;
  87. pEndPoint.y = _oAreaBottom.y + 50;
  88. pEndPointBounce.x = pEndPoint.x + 10;
  89. pEndPointBounce.y = pEndPoint.y - 10;
  90. }
  91. break;
  92. case END_POINT_X_PERFECT_LEFT:
  93. _iArea = 3;
  94. s_bBounce = false;
  95. pEndPoint.x -= 30;
  96. pEndPoint.y = _oCrowdLeft.y + 30;
  97. break;
  98. case END_POINT_X_PERFECT_RIGHT:
  99. _iArea = 2;
  100. s_bBounce = false;
  101. pEndPoint.y = _oCrowdRight.y + 30;
  102. break;
  103. }
  104. var _oStadiumBallContainer = new createjs.Container();
  105. s_oStage.addChild(_oStadiumBallContainer);
  106. _oBall = new CStadiumBall(pStartPoint, pEndPoint, pEndPointBounce, _oStadiumBallContainer, _iArea, oHitValue);
  107. _bUpdate = true;
  108. };
  109. this.update = function(){
  110. if(_bUpdate){
  111. _oBall.update();
  112. }
  113. };
  114. this.viewAreaEffect = function(iArea, iScore){
  115. switch(iArea){
  116. case 0:
  117. createjs.Tween.get(_oAreaBottom).to({alpha:1 }, 300).call(function() {
  118. createjs.Tween.get(_oAreaBottom).to({alpha:0.5 }, 300).call(function() {
  119. createjs.Tween.get(_oAreaBottom).to({alpha:1 }, 300).call(function() {
  120. createjs.Tween.get(_oAreaBottom).to({alpha:0.5 }, 300).call(function() {
  121. var oPanel = new CPanel(iScore);
  122. s_oGame._setScore(iScore);
  123. });
  124. });
  125. });
  126. });
  127. break;
  128. case 1:
  129. createjs.Tween.get(_oAreaTop).to({alpha:1 }, 300).call(function() {
  130. createjs.Tween.get(_oAreaTop).to({alpha:0.5 }, 300).call(function() {
  131. createjs.Tween.get(_oAreaTop).to({alpha:1 }, 300).call(function() {
  132. createjs.Tween.get(_oAreaTop).to({alpha:0.5 }, 300).call(function() {
  133. var oPanel = new CPanel(iScore);
  134. s_oGame._setScore(iScore);
  135. });
  136. });
  137. });
  138. });
  139. break;
  140. case 2:
  141. createjs.Tween.get(_oCrowdLeft).to({alpha:1 }, 300).call(function() {
  142. createjs.Tween.get(_oCrowdLeft).to({alpha:0.5 }, 300).call(function() {
  143. createjs.Tween.get(_oCrowdLeft).to({alpha:1 }, 300).call(function() {
  144. createjs.Tween.get(_oCrowdLeft).to({alpha:0.5 }, 300).call(function() {
  145. var oPanel = new CPanel(iScore);
  146. s_oGame._setScore(iScore);
  147. });
  148. });
  149. });
  150. });
  151. break;
  152. case 3:
  153. createjs.Tween.get(_oCrowdRight).to({alpha:1 }, 300).call(function() {
  154. createjs.Tween.get(_oCrowdRight).to({alpha:0.5 }, 300).call(function() {
  155. createjs.Tween.get(_oCrowdRight).to({alpha:1 }, 300).call(function() {
  156. createjs.Tween.get(_oCrowdRight).to({alpha:0.5 }, 300).call(function() {
  157. var oPanel = new CPanel(iScore);
  158. s_oGame._setScore(iScore);
  159. });
  160. });
  161. });
  162. });
  163. break;
  164. }
  165. };
  166. this.unload = function(){
  167. if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
  168. _oAudioToggle.unload();
  169. _oAudioToggle = null;
  170. }
  171. oStadiumContainer.removeAllChildren();
  172. s_oStadium = null;
  173. };
  174. this.setVisible = function(){
  175. _oStadiumContainer.visible = true;
  176. };
  177. this.setInvisible = function(){
  178. _oStadiumContainer.visible = false;
  179. _oBall.unload();
  180. };
  181. s_oStadium = this;
  182. this._init();
  183. return this;
  184. }
  185. var s_oStadium = null;