CEndPanel.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. function CEndPanel(){
  2. var _oBg;
  3. var _oScoreText;
  4. var _oMsgText;
  5. var _oRestartBut;
  6. var _oGroup;
  7. this._init = function(){
  8. _oGroup = new createjs.Container();
  9. _oGroup.visible=false;
  10. s_oStage.addChild(_oGroup);
  11. _oBg = createBitmap(s_oSpriteLibrary.getSprite('gameover_bg'));
  12. _oGroup.addChild(_oBg);
  13. var iWidth = 550;
  14. var iHeight = 90;
  15. var iX = CANVAS_WIDTH/2;
  16. var iY = CANVAS_HEIGHT/2 - 132;
  17. _oMsgText = new CTLText(_oGroup,
  18. iX-iWidth/2, iY-iHeight/2, iWidth, iHeight,
  19. 80, "center", FONT_COLOR, FONT_GAME, 1,
  20. 2, 2,
  21. " ",
  22. true, true, false,
  23. false );
  24. _oMsgText.setShadow("#000", 2,2,2);
  25. var iWidth = 550;
  26. var iHeight = 60;
  27. var iX = CANVAS_WIDTH/2;
  28. var iY = CANVAS_HEIGHT/2 + 52;
  29. _oScoreText = new CTLText(_oGroup,
  30. iX-iWidth/2, iY-iHeight/2, iWidth, iHeight,
  31. 50, "center", FONT_COLOR, FONT_GAME, 1,
  32. 2, 2,
  33. " ",
  34. true, true, false,
  35. false );
  36. _oScoreText.setShadow("#000", 2,2,2);
  37. var oSprite = s_oSpriteLibrary.getSprite('but_play');
  38. _oRestartBut = new CTextButton((CANVAS_WIDTH/2),CANVAS_HEIGHT -280,oSprite,TEXT_RESTART,FONT_GAME,"#ffc600",60,_oGroup);
  39. _oRestartBut.addEventListener(ON_MOUSE_UP, this._onButRestartRelease, this);
  40. };
  41. this.unload = function(){
  42. _oGroup.off("mousedown",this._onExit);
  43. };
  44. this._initListener = function(){
  45. _oGroup.on("mousedown",this._onExit);
  46. };
  47. this.show = function(iScore){
  48. _oMsgText.refreshText( TEXT_GAMEOVER );
  49. _oScoreText.refreshText( sprintf(TEXT_SCORE, iScore) );
  50. _oGroup.visible = true;
  51. $(s_oMain).trigger("save_score",iScore);
  52. $(s_oMain).trigger("show_interlevel_ad");
  53. };
  54. this._onExit = function(){
  55. _oGroup.off("mousedown",this._onExit);
  56. s_oStage.removeChild(_oGroup);
  57. s_oGame.onExit();
  58. };
  59. this._onButRestartRelease = function(){
  60. s_oStage.removeAllChildren();
  61. $(s_oMain).trigger("restart_level",1);
  62. s_oMain.gotoGame();
  63. };
  64. this._init();
  65. return this;
  66. }