CChangeLevel.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. function CChangeLevel(oSpriteBg){
  2. var _oBg;
  3. var _oCongratsText;
  4. var _oMsgText;
  5. var _oTargetText;
  6. var _oButStart;
  7. var _oGroup;
  8. this._init = function(oSpriteBg){
  9. _oBg = createBitmap(oSpriteBg);
  10. _oCongratsText = new createjs.Text(TEXT_WIN,"50px "+FONT_GAME, "#ffffff");
  11. _oCongratsText.x = CANVAS_WIDTH/2;
  12. _oCongratsText.y = (CANVAS_HEIGHT/2)-150;
  13. _oCongratsText.textAlign = "center";
  14. _oMsgText = new createjs.Text("","40px "+FONT_GAME, "#ffffff");
  15. _oMsgText.x = CANVAS_WIDTH/2;
  16. _oMsgText.y = (CANVAS_HEIGHT/2) - 30;
  17. _oMsgText.textAlign = "center";
  18. _oTargetText = new createjs.Text("","30px "+FONT_GAME, "#ffffff");
  19. _oTargetText.x = CANVAS_WIDTH/2;
  20. _oTargetText.y = (CANVAS_HEIGHT/2) + 90;
  21. _oTargetText.textAlign = "center";
  22. _oButStart = new createjs.Shape();
  23. _oButStart.graphics.beginFill("yellow").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);
  24. _oButStart.alpha = 0.01;
  25. _oGroup = new createjs.Container();
  26. _oGroup.alpha = 0;
  27. _oGroup.visible=false;
  28. _oGroup.addChild(_oBg, _oButStart,_oCongratsText,_oMsgText,_oTargetText);
  29. s_oStage.addChild(_oGroup);
  30. var oParent = this;
  31. _oButStart.on("pressup",function(){oParent._onChangeLevel();});
  32. };
  33. this.show = function(iLevel,iTarget){
  34. _oMsgText.text = TEXT_LEVEL + " "+iLevel + " "+TEXT_PASSED;
  35. _oTargetText.text = TEXT_TARGET + ": "+iTarget+"$";
  36. _oGroup.visible = true;
  37. createjs.Tween.get(_oGroup).to({alpha:1 }, 500).call(function(){
  38. if(iLevel>1){
  39. $(s_oMain).trigger("show_interlevel_ad");
  40. }
  41. });
  42. };
  43. this._onChangeLevel = function(){
  44. var oParent = this;
  45. _oButStart.off("pressup",function(){oParent._onChangeLevel();});
  46. s_oStage.removeChild(_oGroup);
  47. s_oGame.changeLevel();
  48. };
  49. this._init(oSpriteBg);
  50. }