CGameOver.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. function CGameOver(){
  2. var _oMsgTextBack;
  3. var _oMsgTextScore;
  4. var _oContinueButton;
  5. var _oGroup;
  6. this._init = function(){
  7. _oGroup = new createjs.Container();
  8. _oGroup.alpha = 0;
  9. _oGroup.visible = false;
  10. s_oStage.addChild(_oGroup);
  11. var oBg = createBitmap(s_oSpriteLibrary.getSprite('msg_box'));
  12. _oGroup.addChild(oBg);
  13. _oMsgTextBack = new CTLText(_oGroup,
  14. CANVAS_WIDTH/2-300, (CANVAS_HEIGHT/2) - 120, 600, 50,
  15. 50, "center", "#fff", FONT_GAME, 1,
  16. 0, 0,
  17. TEXT_GAMEOVER,
  18. true, true, false,
  19. false );
  20. _oMsgTextBack.setShadow("#000000", 3, 3, 2);
  21. _oMsgTextScore = new CTLText(_oGroup,
  22. CANVAS_WIDTH/2-300, (CANVAS_HEIGHT/2), 600, 48,
  23. 48, "center", "Pink", FONT_GAME, 1,
  24. 0, 0,
  25. TEXT_TOTALSCORE+ " 0",
  26. true, true, false,
  27. false );
  28. _oMsgTextScore.setShadow("#000000", 2, 2, 2);
  29. _oContinueButton = new CTextButton(CANVAS_WIDTH/2,700,
  30. s_oSpriteLibrary.getSprite('but_menu_bg'),
  31. TEXT_PLAY_AGAIN,
  32. FONT_GAME,
  33. "White",
  34. "24",
  35. _oGroup);
  36. _oContinueButton.addEventListener(ON_MOUSE_UP, this.unload, this);
  37. }
  38. this.display = function(iScore){
  39. _oMsgTextScore.refreshText(TEXT_TOTALSCORE + " " + iScore);
  40. _oGroup.visible = true;
  41. createjs.Tween.get(_oGroup).to({alpha:1},250).call(function(){$(s_oMain).trigger("show_interlevel_ad");});
  42. console.log("Game over");
  43. $(s_oMain).trigger("save_score",iScore);
  44. $(s_oMain).trigger("game_over",iScore);
  45. };
  46. this.unload = function(){
  47. _oContinueButton.unload();
  48. s_oStage.removeChild(_oGroup);
  49. s_oGame.unload(false);
  50. };
  51. this._init();
  52. }