CEndPanel.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. function CEndPanel(iTimeLeft,iScore,iShots,refGame){
  2. var _refGame;
  3. var _oListener;
  4. var _oSprPanel;
  5. var _oTextScore;
  6. var _oTextShots;
  7. var _oTextTime;
  8. var _oTextSuccessPerc;
  9. var _oButReplay;
  10. this._init = function(iTimeLeft,iScore,iShots,refGame){
  11. _refGame = refGame;
  12. _oSprPanel = createBitmap(s_oSpriteLibrary.getSprite('msg_box'));
  13. _oListener = _oSprPanel.on("click",function(){});
  14. s_oStage.addChild(_oSprPanel);
  15. var _szFinalScore = TEXT_FINALSCORE + " "+iScore;
  16. _oTextScore = new CTLText(s_oStage,
  17. CANVAS_WIDTH/2-250, 205, 500, 52,
  18. 52, "center", "#FFCC00", FONT_GAME, 1,
  19. 0, 0,
  20. _szFinalScore,
  21. true, true, false,
  22. false );
  23. _oTextScore.setAlpha(0);
  24. _oTextScore.setShadow("#000000", 4, 4, 3);
  25. createjs.Tween.get(_oTextScore.getText()).to({x:CANVAS_WIDTH/2,y:(CANVAS_HEIGHT/2) - 130,alpha:1}, 1600,createjs.Ease.quadOut);
  26. var _szFinalShots = TEXT_FINALSHOTS + " "+iShots;
  27. _oTextShots = new CTLText(s_oStage,
  28. CANVAS_WIDTH/2-250, (CANVAS_HEIGHT/2) - 85, 500, 52,
  29. 36, "center", "#FFCC00", FONT_GAME, 1,
  30. 0, 0,
  31. _szFinalShots,
  32. true, true, false,
  33. false );
  34. _oTextShots.setAlpha(0);
  35. _oTextShots.setShadow("#000000", 3, 3, 3);
  36. createjs.Tween.get(_oTextShots.getText()).wait(500).to({alpha:1}, 500,createjs.Ease.quadOut);
  37. if(iTimeLeft <= 0){
  38. iTimeLeft = 0;
  39. }else{
  40. iTimeLeft = formatTime(iTimeLeft);
  41. }
  42. var _szFinalTime = TEXT_FINALTIME + " "+ iTimeLeft;
  43. _oTextTime = new CTLText(s_oStage,
  44. CANVAS_WIDTH/2-250, (CANVAS_HEIGHT/2) - 30, 500, 52,
  45. 36, "center", "#FFCC00", FONT_GAME, 1,
  46. 0, 0,
  47. _szFinalTime,
  48. true, true, false,
  49. false );
  50. _oTextTime.setAlpha(0);
  51. _oTextTime.setShadow("#000000", 3, 3, 3);
  52. createjs.Tween.get(_oTextTime.getText()).wait(750).to({alpha:1}, 500,createjs.Ease.quadOut);
  53. var succP;
  54. if (iShots === 0) {succP=0;} else{succP=((iScore/iShots)*100).toFixed(1);};
  55. var _szFinalSuccPerc = TEXT_FINALSUCCESSPERC + " "+succP + "%";
  56. _oTextSuccessPerc = new CTLText(s_oStage,
  57. CANVAS_WIDTH/2-250, (CANVAS_HEIGHT/2) +25, 500, 52,
  58. 36, "center", "#FFCC00", FONT_GAME, 1,
  59. 0, 0,
  60. _szFinalSuccPerc,
  61. true, true, false,
  62. false );
  63. _oTextSuccessPerc.setAlpha(0);
  64. _oTextSuccessPerc.setShadow("#000000", 3, 3, 3);
  65. var that = this;
  66. createjs.Tween.get(_oTextSuccessPerc.getText())
  67. .wait(1000)
  68. .to({alpha:1}, 500,createjs.Ease.quadOut)
  69. .call(function(){
  70. var oSprite = s_oSpriteLibrary.getSprite('but_play');
  71. _oButReplay = new CTextButton(CANVAS_WIDTH/2,CANVAS_HEIGHT/2 + 125,oSprite,TEXT_PLAYAGAIN,FONT_GAME,"#ffffff",30,s_oStage);
  72. _oButReplay.addEventListener(ON_MOUSE_UP, that._onButPlayAgain, that);
  73. $(s_oMain).trigger("show_interlevel_ad");
  74. },that);
  75. $(s_oMain).trigger("save_score",iScore);
  76. $(s_oMain).trigger("end_level");
  77. };
  78. this.unload = function(){
  79. _oSprPanel.off("click",_oListener);
  80. _oButReplay.unload();
  81. _oButReplay = null;
  82. };
  83. this._onButPlayAgain = function(){
  84. _refGame.unload();
  85. };
  86. this._init(iTimeLeft,iScore,iShots,refGame);
  87. }