Hello.
I faced strange issue in cocos2d js.
In the first scene,the game change running scene to the second scene using pushScene function.
But when the game call popScene function in the second scene,the running scene didn’t changed into first scene what called pushScene function.
If any developer knows about it,then please help me.
Thanks.
First Scene
var IntroLayer = cc.Layer.extend({
sprite:null,
ctor:function(){
this._super();
var size = cc.winSize;
var winSize = cc.winSize;
var background = new cc.Sprite(res.temno_png, new cc.Rect(0, 0, winSize.width, winSize.height));
background.setPosition(new cc.p(winSize.width/2,winSize.height/2));
this.addChild(background);
background.setScale(0.5);
return true;
},
onEnter:function(){
this._super();
this.getDailyBonus();
},
getDailyBonus:function () {
var hasdailyBonus = false;
var buf;
for (var i = 0; i < 30; i++)
{
buf = "day_bonus" + (i + 1);
if (cc.sys.localStorage.getItem(buf) == 1)
{
hasdailyBonus = true;
break;
}
}
var scene = new DailyBonusScene();
//var transition = new cc.TransitionCrossFade()
cc.director.pushScene(scene);
}
});
var IntroScene = cc.Scene.extend({
ctor:function () {
this._super();
var layer = new IntroLayer();
this.addChild(layer);
}
});
##Second Scene##
var DailyBonusLayer = cc.Layer.extend({
selectedItem : null,
tutorTime : 0.0,
tutorTTF : null,
temnoBg :null,
characterArray : null,
sPoint:null,
ePoint:null,
cPoint:null,
touchStatus : false,
bonusPad : null,
curOrder : 0,
start_pos_x : 0.0,
tutor_temno : null,
tutorSp : null,
ballonSp:null,
tutorShineSp:null,
particle:null,
ctor:function () {
//////////////////////////////
// 1. super init first
this._super();
// setTouchEnabled(true);
var winSize = cc.winSize;
var backSp = new cc.Sprite(res.background_jpg);
var fX = winSize.width / backSp.getContentSize().width;
var fY = winSize.height / backSp.getContentSize().height;
backSp.setScaleX(fX);
backSp.setScaleY(fY);
this.addChild(backSp , 0 , 10);
backSp.setPosition(new cc.p(winSize.width / 2, winSize.height - backSp.getBoundingBox().height / 2));
bonusPad = new cc.Sprite(res.bonus_pad_png);
this.addChild(bonusPad);
bonusPad.setScale(0.7);
bonusPad.setPosition(new cc.p(winSize.width / 2, winSize.height / 2));
{
var topSp = new cc.Sprite("#return_bonus_top_1.png");
var animation_top = cc.animationCache.getAnimation("ReturnBonusTop");
topSp.runAction(new cc.repeatForever(new cc.animate(animation_top)));
bonusPad.addChild(topSp);
topSp.setPosition(new cc.p(459, 515));
var topTitle = new cc.LabelBMFont("RETURN BONUS","fonts/Gold_1.fnt");
bonusPad.addChild(topTitle);
topTitle.setPosition(new cc.p(484, 566));
topTitle.setScale(0.5);
}
var leftSp = new cc.Sprite(res.background_jpg, new cc.Rect(0,0,(winSize.width/2 - (bonusPad.getContentSize().width/2 - 26) * /*fScaleN*/1 ) / fX , 721));
leftSp.setScaleX(fX);
leftSp.setScaleY(fY);
this.addChild(leftSp, 10);
leftSp.setPosition(new cc.p(leftSp.getBoundingBox().width/2,winSize.height/2));
leftSp = new cc.Sprite(res.bonus_pad_png, new cc.Rect(0, 0, 26, 627));
leftSp.setScale(fScaleN);
this.addChild(leftSp, 10);
leftSp.setPosition(new cc.p(bonusPad.getPositionX() - bonusPad.getBoundingBox().width/2 + leftSp.getBoundingBox().width/2, winSize.height / 2));
var rightPos = (winSize.width / 2 + (bonusPad.getContentSize().width / 2 - 28) * /*fScaleN*/1) / fX;
var rightSp = new cc.Sprite(res.background_jpg,new cc.Rect(rightPos, 0, 1280-rightPos, 721));
rightSp.setScaleX(fX);
rightSp.setScaleY(fY);
this.addChild(rightSp, 10);
rightSp.setPosition(new cc.p(winSize.width - rightSp.getBoundingBox().width / 2, winSize.height / 2));
rightSp = new cc.Sprite(res.bonus_pad_png, new cc.Rect(936, 0, 36, 627));
//rightSp.setScale(fScaleN);
this.addChild(rightSp, 10);
rightSp.setPosition(new cc.p(bonusPad.getPositionX() + bonusPad.getBoundingBox().width / 2 - rightSp.getBoundingBox().width / 2, winSize.height / 2));
var closeSp =new cc.Sprite("#menu_close.png");
//closeSp.setOpacity(0);
var closeBtn = new cc.MenuItemSprite(closeSp, null, this.backAction,this);
closeBtn.setPosition(new cc.p(938, 594));
var closeMnu = new cc.Menu(closeBtn);
closeMnu.setPosition(new cc.p(0,0));
bonusPad.addChild(closeMnu, 1);
return true;
},
backAction:function(pSender){
// if (!sfxOff)
// cc.audioEngine.playEffect(sName[kSFXMenuButtonClick]);
if (cc.sys.localStorage.getItem("Tutor") == 1)
return;
var buf;
for (var i = 0; i < 30; i++)
{
buf = "day_bonus" + (i + 1);
if (cc.sys.localStorage.getItem(buf) == 1)
{
var bonus = bonus_base[i] * (1.1 + _cData.stageCount * 0.04 )*( 1.1 );
_cData.memload += bonus;
cc.sys.localStorage.setItem(buf, 2);
}
}
cc.director.popScene();
}
});
var DailyBonusScene = cc.Scene.extend({
ctor:function () {
this._super();
var layer = new DailyBonusLayer();
this.addChild(layer);
}
});