Skip to content

Commit

Permalink
remove credits and delete results button
Browse files Browse the repository at this point in the history
  • Loading branch information
parabolabam committed Oct 1, 2024
1 parent 3ecd433 commit 4000b22
Showing 1 changed file with 212 additions and 142 deletions.
354 changes: 212 additions & 142 deletions js/CMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,157 +18,227 @@ function CMenu(){
var _pStartPosFullscreen;
var _pStartPosDelete;

this._init = function(){
//console.clear();
var oSprite = s_oSpriteLibrary.getSprite('bg_menu');
_oBg = createBitmap(oSprite);
_oBg.x = CANVAS_WIDTH/2;
_oBg.y = CANVAS_HEIGHT/2;
_oBg.regX = oSprite.width/2;
_oBg.regY = oSprite.height/2;
s_oStage.addChild(_oBg);


var oSprite = s_oSpriteLibrary.getSprite('logo_menu');
_oLogo = createBitmap(oSprite);
_oLogo.regX = oSprite.width/2;
_oLogo.regY = oSprite.height/2;
_oLogo.x = CANVAS_WIDTH/2;
_oLogo.y = CANVAS_HEIGHT/2-350;
_oLogo.scale = 0.6;
s_oStage.addChild(_oLogo);

var oSpriteStart = s_oSpriteLibrary.getSprite('but_play');
_oButPlay = new CGfxButton(CANVAS_WIDTH/2,CANVAS_HEIGHT/2 + 500,oSpriteStart,s_oStage);
_oButPlay.addEventListener(ON_MOUSE_UP, this._onButPlayRelease, this);
_oButPlay.pulseAnimation();
this._init = function () {
//console.clear();
var oSprite = s_oSpriteLibrary.getSprite("bg_menu");
_oBg = createBitmap(oSprite);
_oBg.x = CANVAS_WIDTH / 2;
_oBg.y = CANVAS_HEIGHT / 2;
_oBg.regX = oSprite.width / 2;
_oBg.regY = oSprite.height / 2;
s_oStage.addChild(_oBg);


_oScoreContainer = new createjs.Container();
_oScoreContainer.x = _oButPlay.getX();
_oScoreContainer.y = _oButPlay.getY()+210;
s_oStage.addChild(_oScoreContainer);

var oSprite = s_oSpriteLibrary.getSprite('star');
var oStar = createBitmap(oSprite);
oStar.regX = oSprite.width/2;
oStar.regY = oSprite.height/2;
_oScoreContainer.addChild(oStar);

var iTotalScore = 0;
for(var i=0; i<s_aLevelScore.length; i++){
iTotalScore += s_aLevelScore[i];

}

_oScoreText = new CTLText(_oScoreContainer,
50, -50, 250, 100,
80, "left", "#fff", PRIMARY_FONT, 1,
0, 0,
iTotalScore+"",
true, true, false,
false );
_oScoreText.setStroke(10,"#000");

///CENTER THE TEXT
_oScoreContainer.x = _oButPlay.getX() - _oScoreText.getTextWidth()/2;

var oSprite = s_oSpriteLibrary.getSprite('but_credits');
_pStartPosCredits = {x: (oSprite.width/2) + 10, y: (oSprite.height/2) + 10};
_oCreditsBut = new CGfxButton(_pStartPosCredits.x,_pStartPosCredits.y,oSprite, s_oStage);
_oCreditsBut.addEventListener(ON_MOUSE_UP, this._onCreditsBut, this);


if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
var oSprite = s_oSpriteLibrary.getSprite('audio_icon');
_pStartPosAudio = {x: CANVAS_WIDTH - (oSprite.height/2) - 10, y: (oSprite.height/2) + 10};
_oAudioToggle = new CToggle(_pStartPosAudio.x,_pStartPosAudio.y,oSprite,s_bAudioActive,s_oStage);
_oAudioToggle.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this);
}

var oSprite = s_oSpriteLibrary.getSprite('but_delete_saving');
_pStartPosDelete = {x: CANVAS_WIDTH - (oSprite.width/2) - 12, y: CANVAS_HEIGHT - (oSprite.height/2) - 16};
_oButDelete = new CGfxButton(_pStartPosDelete.x,_pStartPosDelete.y,oSprite, s_oStage);
_oButDelete.addEventListener(ON_MOUSE_UP, this._onDeleteBut, this);

if(!s_oLocalStorage.isDirty()){
_oButDelete.setVisible(false);
}

var doc = window.document;
var docEl = doc.documentElement;
_fRequestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
_fCancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
var oSprite = s_oSpriteLibrary.getSprite("logo_menu");
_oLogo = createBitmap(oSprite);
_oLogo.regX = oSprite.width / 2;
_oLogo.regY = oSprite.height / 2;
_oLogo.x = CANVAS_WIDTH / 2;
_oLogo.y = CANVAS_HEIGHT / 2 - 350;
_oLogo.scale = 0.6;
s_oStage.addChild(_oLogo);

if(ENABLE_FULLSCREEN === false){
_fRequestFullScreen = false;
}
var oSpriteStart = s_oSpriteLibrary.getSprite("but_play");
_oButPlay = new CGfxButton(
CANVAS_WIDTH / 2,
CANVAS_HEIGHT / 2 + 500,
oSpriteStart,
s_oStage
);
_oButPlay.addEventListener(ON_MOUSE_UP, this._onButPlayRelease, this);
_oButPlay.pulseAnimation();

if (_fRequestFullScreen && screenfull.isEnabled){
oSprite = s_oSpriteLibrary.getSprite("but_fullscreen")
_pStartPosFullscreen = {x:_pStartPosCredits.x + oSprite.width/2 + 10,y:(oSprite.height/2) + 10};
_oButFullscreen = new CToggle(_pStartPosFullscreen.x,_pStartPosFullscreen.y,oSprite,s_bFullscreen, s_oStage);
_oButFullscreen.addEventListener(ON_MOUSE_UP,this._onFullscreenRelease,this);
}
// _oScoreContainer = new createjs.Container();
// _oScoreContainer.x = _oButPlay.getX();
// _oScoreContainer.y = _oButPlay.getY() + 210;
// s_oStage.addChild(_oScoreContainer);

// var oSprite = s_oSpriteLibrary.getSprite('star');
// var oStar = createBitmap(oSprite);
// oStar.regX = oSprite.width/2;
// oStar.regY = oSprite.height/2;
// _oScoreContainer.addChild(oStar);

var iTotalScore = 0;
for (var i = 0; i < s_aLevelScore.length; i++) {
iTotalScore += s_aLevelScore[i];
}

_oFade = new createjs.Shape();
_oFade.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);

s_oStage.addChild(_oFade);

createjs.Tween.get(_oFade).to({alpha:0}, 1000).call(function(){_oFade.visible = false;});

this.refreshButtonPos();

if(!s_oLocalStorage.isUsed()){
new CMsgBox(TEXT_IOS_PRIVATE);
}
// _oScoreText = new CTLText(_oScoreContainer,
// 50, -50, 250, 100,
// 80, "left", "#fff", PRIMARY_FONT, 1,
// 0, 0,
// iTotalScore+"",
// true, true, false,
// false );
// _oScoreText.setStroke(10,"#000");

///CENTER THE TEXT
// _oScoreContainer.x = _oButPlay.getX() - _oScoreText.getTextWidth() / 2;

var oSprite = s_oSpriteLibrary.getSprite("but_credits");
_pStartPosCredits = {
x: oSprite.width / 2 + 10,
y: oSprite.height / 2 + 10,
};
_oCreditsBut = new CGfxButton(
_pStartPosCredits.x,
_pStartPosCredits.y,
oSprite,
s_oStage
);
_oCreditsBut.setVisible(false);
_oCreditsBut.setClickable(false);
_oCreditsBut.addEventListener(ON_MOUSE_UP, this._onCreditsBut, this);

if (DISABLE_SOUND_MOBILE === false || s_bMobile === false) {
var oSprite = s_oSpriteLibrary.getSprite("audio_icon");
_pStartPosAudio = {
x: CANVAS_WIDTH - oSprite.height / 2 - 10,
y: oSprite.height / 2 + 10,
};
_oAudioToggle = new CToggle(
_pStartPosAudio.x,
_pStartPosAudio.y,
oSprite,
s_bAudioActive,
s_oStage
);
_oAudioToggle.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this);
}

var oSprite = s_oSpriteLibrary.getSprite("but_delete_saving");
_pStartPosDelete = {
x: CANVAS_WIDTH - oSprite.width / 2 - 12,
y: CANVAS_HEIGHT - oSprite.height / 2 - 16,
};
_oButDelete = new CGfxButton(
_pStartPosDelete.x,
_pStartPosDelete.y,
oSprite,
s_oStage
);

_oButDelete.setVisible(false);
_oButDelete.setClickable(false);

if (!s_oLocalStorage.isDirty()) {
_oButDelete.setVisible(false);
}

var doc = window.document;
var docEl = doc.documentElement;
_fRequestFullScreen =
docEl.requestFullscreen ||
docEl.mozRequestFullScreen ||
docEl.webkitRequestFullScreen ||
docEl.msRequestFullscreen;
_fCancelFullScreen =
doc.exitFullscreen ||
doc.mozCancelFullScreen ||
doc.webkitExitFullscreen ||
doc.msExitFullscreen;

if (ENABLE_FULLSCREEN === false) {
_fRequestFullScreen = false;
}

if (_fRequestFullScreen && screenfull.isEnabled) {
oSprite = s_oSpriteLibrary.getSprite("but_fullscreen");
_pStartPosFullscreen = {
x: oSprite.width / 2 + 10,
y: oSprite.height / 2 + 10,
};
_oButFullscreen = new CToggle(
0,
_pStartPosFullscreen.y,
oSprite,
s_bFullscreen,
s_oStage
);
_oButFullscreen.addEventListener(
ON_MOUSE_UP,
this._onFullscreenRelease,
this
);
}

_oFade = new createjs.Shape();
_oFade.graphics
.beginFill("black")
.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);

s_oStage.addChild(_oFade);

createjs.Tween.get(_oFade)
.to({ alpha: 0 }, 1000)
.call(function () {
_oFade.visible = false;
});

this.refreshButtonPos();

if (!s_oLocalStorage.isUsed()) {
new CMsgBox(TEXT_IOS_PRIVATE);
}
};

this.unload = function(){
_oButPlay.unload();
_oCreditsBut.unload();

if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
_oAudioToggle.unload();
_oAudioToggle = null;
}

if (_fRequestFullScreen && screenfull.isEnabled){
_oButFullscreen.unload();
}

s_oMenu = null;
s_oStage.removeAllChildren();
this.unload = function () {
_oButPlay.unload();
_oCreditsBut.unload();

if (DISABLE_SOUND_MOBILE === false || s_bMobile === false) {
_oAudioToggle.unload();
_oAudioToggle = null;
}

if (_fRequestFullScreen && screenfull.isEnabled) {
_oButFullscreen.unload();
}

s_oMenu = null;
s_oStage.removeAllChildren();
};

this.refreshButtonPos = function(){
if(s_bLandscape){
_oButPlay.setPosition(CANVAS_WIDTH/2, CANVAS_HEIGHT-150-s_iOffsetY);
_oScoreContainer.x = s_iOffsetX + 60;
_oScoreContainer.y = CANVAS_HEIGHT - 60 -s_iOffsetY;

_oLogo.y = CANVAS_HEIGHT/2-310;
}else{
_oButPlay.setPosition(CANVAS_WIDTH/2, CANVAS_HEIGHT/2 + 500);
_oScoreContainer.y = _oButPlay.getY()+210;
_oScoreContainer.x = _oButPlay.getX() - _oScoreText.getTextWidth()/2;

_oLogo.y = CANVAS_HEIGHT/2-350;
}

if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
_oAudioToggle.setPosition(_pStartPosAudio.x - s_iOffsetX,s_iOffsetY + _pStartPosAudio.y);
}

if (_fRequestFullScreen && screenfull.isEnabled){
_oButFullscreen.setPosition(_pStartPosFullscreen.x + s_iOffsetX, _pStartPosFullscreen.y + s_iOffsetY);
}

_oCreditsBut.setPosition(_pStartPosCredits.x + s_iOffsetX,s_iOffsetY + _pStartPosCredits.y);
_oButDelete.setPosition(_pStartPosDelete.x - s_iOffsetX,_pStartPosDelete.y - s_iOffsetY);

this.refreshButtonPos = function () {
if (s_bLandscape) {
_oButPlay.setPosition(
CANVAS_WIDTH / 2,
CANVAS_HEIGHT - 150 - s_iOffsetY
);
// _oScoreContainer.x = s_iOffsetX + 60;
// _oScoreContainer.y = CANVAS_HEIGHT - 60 -s_iOffsetY;

_oLogo.y = CANVAS_HEIGHT / 2 - 310;
} else {
_oButPlay.setPosition(CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2 + 500);
// _oScoreContainer.y = _oButPlay.getY()+210;
// _oScoreContainer.x = _oButPlay.getX() - _oScoreText.getTextWidth()/2;

_oLogo.y = CANVAS_HEIGHT / 2 - 350;
}

if (DISABLE_SOUND_MOBILE === false || s_bMobile === false) {
_oAudioToggle.setPosition(
_pStartPosAudio.x - s_iOffsetX,
s_iOffsetY + _pStartPosAudio.y
);
}

if (_fRequestFullScreen && screenfull.isEnabled) {
_oButFullscreen.setPosition(
_pStartPosFullscreen.x + s_iOffsetX,
_pStartPosFullscreen.y + s_iOffsetY
);
}

_oCreditsBut.setPosition(
_pStartPosCredits.x + s_iOffsetX,
s_iOffsetY + _pStartPosCredits.y
);
_oButDelete.setPosition(
_pStartPosDelete.x - s_iOffsetX,
_pStartPosDelete.y - s_iOffsetY
);
};

this.resetFullscreenBut = function(){
Expand Down

0 comments on commit 4000b22

Please sign in to comment.