Skip to content

Commit 94904ab

Browse files
committed
Merge pull request #3191 from pandamicro/develop
Made cc.LoaderScene compatible with runtime LoaderLayer
2 parents b2229a5 + e29e350 commit 94904ab

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

cocos2d/core/CCDirector.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -726,12 +726,12 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{
726726
var locScenesStack = this._scenesStack;
727727
var c = locScenesStack.length;
728728

729-
if (c === 0) {
729+
if (level === 0) {
730730
this.end();
731731
return;
732732
}
733-
// current level or lower -> nothing
734-
if (level > c)
733+
// stack overflow
734+
if (level >= c)
735735
return;
736736

737737
// pop stack until reaching desired level
@@ -745,7 +745,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{
745745
c--;
746746
}
747747
this._nextScene = locScenesStack[locScenesStack.length - 1];
748-
this._sendCleanupToScene = false;
748+
this._sendCleanupToScene = true;
749749
},
750750

751751
/**

extensions/runtime/CCLoaderLayer.js

+24-9
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ cc.LoaderLayer = cc.Layer.extend({
135135
//tips
136136
if (config.tips.show) {
137137
this.tipsLabel = new cc.LabelTTF("100%", "Arial", config.tips.fontSize);
138-
this.tipsLabel.setColor(config.tips.color);
138+
this.tipsLabel.setColor(config.tips.color ? config.tips.color : cc.color(255, 255, 255));
139139
this.tipsLabel.setPosition(config.tips.position ? config.tips.position : this.progressBackgroundSprite ? cc.p(this.progressBackgroundSprite.x, this.progressBackgroundSprite.y + this.progressBackgroundSprite.height / 2 + 20) : cc.pAdd(cc.visibleRect.bottom, cc.p(0, 100)));
140140
this._contentLayer.addChild(this.tipsLabel);
141141
}
@@ -421,20 +421,20 @@ cc.LoaderLayer.preload = function (groupname, callback, target) {
421421
}
422422
}
423423
var callPreload = function () {
424-
if (cc.director.getRunningScene()) {
425-
loaderLayer.updateGroup(groupname, preloadCb, target);
426-
loaderLayer._addToScene();
427-
loaderLayer._preloadSource();
428-
} else {
429-
cc.log("Current scene is null we can't start preload");
430-
}
424+
loaderLayer.updateGroup(groupname, preloadCb, target);
425+
loaderLayer._addToScene();
426+
loaderLayer._preloadSource();
431427
};
432428

433429
if (res_engine_loaded) {
434430
callPreload();
435431
return;
436432
}
437433

434+
if (!cc.director.getRunningScene()) {
435+
cc.director.runScene(new cc.Scene());
436+
}
437+
438438
// Res engine not loaded, load them
439439
cc.loader.load([
440440
GROUP_JSON_PATH,
@@ -470,7 +470,7 @@ cc.LoaderLayer.preload = function (groupname, callback, target) {
470470

471471
cc.LoaderLayer._useDefaultSource = true;
472472
cc.LoaderLayer._isDefaultProgress = true;
473-
cc.LoaderLayer._finalConfig = cc.LoaderLayer._confg;
473+
cc.LoaderLayer._finalConfig = cc.LoaderLayer._config;
474474
cc.LoaderLayer.groups = {};
475475
cc.LoaderLayer.setUseDefaultSource = function (status) {
476476
cc.LoaderLayer._useDefaultSource = status;
@@ -972,3 +972,18 @@ cc.network.preloadstatus = {
972972
cc.runtime.network = cc.network;
973973

974974
})();
975+
976+
cc.LoaderScene._preload = cc.LoaderScene.preload;
977+
cc.LoaderScene.preload = function (arr, cb, target) {
978+
// No extension
979+
var isGroups = (arr[0] && arr[0].indexOf('.') === -1);
980+
if (isGroups) {
981+
if (arr.indexOf('boot') === -1) {
982+
arr.splice(0, 0, 'boot');
983+
}
984+
cc.LoaderLayer.preload(arr, cb, target);
985+
}
986+
else {
987+
cc.LoaderScene._preload(arr, cb, target);
988+
}
989+
}

0 commit comments

Comments
 (0)