Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Refactor #3935 : Change some api about cc.game. #1640

Merged
merged 2 commits into from

2 participants

@SmallAiTT

Refactor #3935 : Change some api about cc.game.
cc.game.onEnter ---> cc.game.onStart
cc.game.onExit ---> cc.game.onStop
Remove cc.game.pause and cc.game.resume.
Change loader plugins to private.

SmallAiTT added some commits
@SmallAiTT SmallAiTT Refactor #3935 : Change some api about cc.game.
`cc.game.onEnter` ---> `cc.game.onStart`
`cc.game.onExit` ---> `cc.game.onStop`
Remove `cc.game.pause` and `cc.game.resume`.
Change loader plugins to private.
72fe8fd
@SmallAiTT SmallAiTT Merge branch 'develop-3.0' of https://github.com/cocos2d/cocos2d-html5
…into CCGame_dev3.0

Conflicts:
	HelloHTML5World/main.js
59ba20a
@dingpinglv dingpinglv merged commit 1c1e8da into cocos2d:develop-3.0
@SmallAiTT SmallAiTT deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 6, 2014
  1. @SmallAiTT

    Refactor #3935 : Change some api about cc.game.

    SmallAiTT authored
    `cc.game.onEnter` ---> `cc.game.onStart`
    `cc.game.onExit` ---> `cc.game.onStop`
    Remove `cc.game.pause` and `cc.game.resume`.
    Change loader plugins to private.
  2. @SmallAiTT

    Merge branch 'develop-3.0' of https://github.com/cocos2d/cocos2d-html5

    SmallAiTT authored
    …into CCGame_dev3.0
    
    Conflicts:
    	HelloHTML5World/main.js
This page is out of date. Refresh to see the latest.
View
63 CCBoot.js
@@ -648,7 +648,7 @@ cc.loader = {
if(url.match(/[\/(\\\\)]lang[\/(\\\\)]/i)){
if(langPathCache[url]) return langPathCache[url];
var extname = path.extname(url) || "";
- url = langPathCache[url] = url.substring(0, url.length - extname.length) + "_" + cc.language.current + extname;
+ url = langPathCache[url] = url.substring(0, url.length - extname.length) + "_" + cc.sys.language + extname;
}
return url;
},
@@ -877,9 +877,8 @@ cc._logToWebPage = function (msg) {
* Init Debug setting.
* @function
*/
-cc._initDebugSetting = function () {
+cc._initDebugSetting = function (mode) {
var ccGame = cc.game;
- var mode = ccGame.config[ccGame.CONFIG_KEY.debugMode];
//log
if(mode == ccGame.DEBUG_MODE_LOG && console.log) {
@@ -956,7 +955,7 @@ cc.create3DContext = function (canvas, opt_attribs) {
return context;
};
//+++++++++++++++++++++++++something about sys begin+++++++++++++++++++++++++++++
-cc._initSys = function(config){
+cc._initSys = function(config, CONFIG_KEY){
/**
* Canvas of render type
* @constant
@@ -1122,23 +1121,22 @@ cc._initSys = function(config){
sys.BROWSER_TYPE_UNKNOWN = "unknown";
/**
+ * Is native ? This is set to be true in jsb auto.
+ * @constant
+ * @type Boolean
+ */
+ sys.isNative = false;
+
+ /**
* WhiteList of browser for WebGL.
* @constant
* @type Array
*/
- sys.WEBGL_WHITE_LIST = [sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_SAFARI];
- sys.MULTIPLE_AUDIO_WHITE_LIST = [
+ var webglWhiteList = [sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_SAFARI];
+ var multipleAudioWhiteList = [
sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME,
sys.BROWSER_TYPE_SAFARI, sys.BROWSER_TYPE_UC, sys.BROWSER_TYPE_QQ, sys.BROWSER_TYPE_MOBILE_QQ
];
- /**
- * Is native ? This is set to be true in jsb auto.
- * @constant
- * @type Boolean
- */
- sys.isNative = false;
-
- var CONFIG_KEY = cc.game.CONFIG_KEY;
var win = window, nav = win.navigator, doc = document, docEle = doc.documentElement;
var ua = nav.userAgent.toLowerCase();
@@ -1167,13 +1165,14 @@ cc._initSys = function(config){
return sys.BROWSER_TYPE_UNKNOWN;
})();
+ sys._supportMultipleAudio = multipleAudioWhiteList.indexOf(sys.browserType) > -1;
//++++++++++++++++++something about cc._renderTYpe and cc._supportRender begin++++++++++++++++++++++++++++
var userRenderMode = parseInt(config[CONFIG_KEY.renderMode]);
var renderType = cc._RENDER_TYPE_WEBGL;
var tempCanvas = document.createElement("Canvas");
cc._supportRender = true;
- var notInWhiteList = sys.WEBGL_WHITE_LIST.indexOf(sys.browserType) == -1;
+ var notInWhiteList = webglWhiteList.indexOf(sys.browserType) == -1;
if(userRenderMode === 1 || (userRenderMode === 0 && (sys.isMobile || notInWhiteList))){
renderType = cc._RENDER_TYPE_CANVAS;
}
@@ -1199,7 +1198,7 @@ cc._initSys = function(config){
// check if browser supports Web Audio
- sys.supportWebAudio = (function () {
+ sys._supportWebAudio = (function () {
// check Web Audio's context
try {
var ctx = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();
@@ -1279,7 +1278,6 @@ cc._initSys = function(config){
str += "isMobile : " + self.isMobile + "\r\n";
str += "language : " + self.language + "\r\n";
str += "browserType : " + self.browserType + "\r\n";
- str += "supportWebAudio : " + self.supportWebAudio + "\r\n";
str += "capabilities : " + JSON.stringify(self.capabilities) + "\r\n";
str += "os : " + self.os + "\r\n";
cc.log(str);
@@ -1504,13 +1502,13 @@ cc.game = {
* Callback when the scripts of engine have been load.
* @type Function
*/
- onEnter : null,
+ onStart : null,
/**
* Callback when game exits.
* @type Function
*/
- onExit : null,
+ onStop : null,
/**
* Callback before game resumes.
* @type Function
@@ -1533,25 +1531,6 @@ cc.game = {
onAfterPause : null,
/**
- * Resume game.
- */
- resume : function(){
- var self = this;
- if(self.onBeforeResume && self.onBeforeResume()) return;
- self._runMainLoop();
- if(self.onAfterResume) self.onAfterResume();
- },
- /**
- * Pause game.
- */
- pause : function(){
- var self = this;
- if(self.onBeforePause && self.onBeforePause()) return;
- if(self._intervalId) clearInterval(self._intervalId);
- self._paused = true;
- if(self.onAfterPause) self.onAfterPause();
- },
- /**
* Set frameRate of game.
* @param frameRate
*/
@@ -1597,7 +1576,7 @@ cc.game = {
if(!cc._supportRender) return;
cc._setup(self.config[self.CONFIG_KEY.id]);
self._runMainLoop();
- self.onEnter();
+ self.onStart();
});
}else{
if(!cc._supportRender) return;
@@ -1605,7 +1584,7 @@ cc.game = {
if(self._prepared){
cc._setup(self.config[self.CONFIG_KEY.id]);
self._runMainLoop();
- self.onEnter();
+ self.onStart();
clearInterval(self._checkPrepare);
}
}, 10);
@@ -1664,12 +1643,12 @@ cc.game = {
var self = this;
self._initConfig(function(config){
var CONFIG_KEY = self.CONFIG_KEY, engineDir = config[CONFIG_KEY.engineDir], loader = cc.loader;
- cc._initSys(config);
+ cc._initSys(config, CONFIG_KEY);
if(!cc._supportRender){
cc.log("Can not support render!")
return;
}
- cc._initDebugSetting();
+ cc._initDebugSetting(config[CONFIG_KEY.debugMode]);
self._prepareCalled = true;
var jsList = config[CONFIG_KEY.jsList] || [];
View
14 cocos2d/audio/CCAudio.js
@@ -33,7 +33,7 @@
* @param {function} setter Setter function for the property
*/
-if (cc.sys.supportWebAudio) {
+if (cc.sys._supportWebAudio) {
var _ctx = cc.webAudioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();
/**
* A class of Web Audio.
@@ -186,7 +186,7 @@ if (cc.sys.supportWebAudio) {
},
canplay : function(){
- return cc.sys.supportWebAudio;
+ return cc.sys._supportWebAudio;
},
_onSuccess : function(buffer){
var self = this;
@@ -274,7 +274,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
ctor:function(){
var self = this;
- self._soundSupported = cc.audioLoader._supportedAudioTypes.length > 0;
+ self._soundSupported = cc._audioLoader._supportedAudioTypes.length > 0;
if(self._effectPauseCb) self._effectPauseCb = self._effectPauseCb.bind(self);
},
@@ -663,7 +663,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
});
-if (!cc.sys.supportWebAudio && cc.sys.MULTIPLE_AUDIO_WHITE_LIST.indexOf(cc.sys.browserType) < 0){
+if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0){
/**
* AudioEngine for single audio mode.
* @class
@@ -971,7 +971,7 @@ cc.defineGetterSetter(cc, "audioEngine", function() {
/**
* Resource loader for audio.
*/
-cc.audioLoader = {
+cc._audioLoader = {
_supportedAudioTypes : null,
getBasePath : function(){
return cc.loader.audioPath;
@@ -1041,7 +1041,7 @@ cc.audioLoader = {
this._load(realUrl, url, res, -1, tryArr, null, cb);
}
};
-cc.audioLoader._supportedAudioTypes = function() {
+cc._audioLoader._supportedAudioTypes = function() {
var au = document.createElement('audio'), arr = [];;
if (au.canPlayType) {
// <audio> tag is supported, go on
@@ -1057,4 +1057,4 @@ cc.audioLoader._supportedAudioTypes = function() {
}
return arr;
}();
-cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], cc.audioLoader);
+cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], cc._audioLoader);
View
79 cocos2d/core/platform/CCLoaders.js
@@ -24,21 +24,21 @@
THE SOFTWARE.
****************************************************************************/
-cc.txtLoader = {
+cc._txtLoader = {
load : function(realUrl, url, res, cb){
cc.loader.loadTxt(realUrl, cb);
}
}
-cc.loader.register(["txt", "xml", "vsh", "fsh"], cc.txtLoader);
+cc.loader.register(["txt", "xml", "vsh", "fsh"], cc._txtLoader);
-cc.jsonLoader = {
+cc._jsonLoader = {
load : function(realUrl, url, res, cb){
cc.loader.loadJson(realUrl, cb);
}
};
-cc.loader.register(["json", "ExportJson"], cc.jsonLoader);
+cc.loader.register(["json", "ExportJson"], cc._jsonLoader);
-cc.imgLoader = {
+cc._imgLoader = {
load : function(realUrl, url, res, cb){
var image = cc.loader.loadImg(realUrl, function(err, img){
if(err) return cb(err);
@@ -48,9 +48,9 @@ cc.imgLoader = {
cc.loader.cache[url] = image;
}
};
-cc.loader.register(["png", "jpg", "bmp","jpeg","gif"], cc.imgLoader);
+cc.loader.register(["png", "jpg", "bmp","jpeg","gif"], cc._imgLoader);
-cc.plistLoader = {
+cc._plistLoader = {
load : function(realUrl, url, res, cb){
cc.loader.loadTxt(realUrl, function(err, txt){
if(err) return cb(err);
@@ -58,66 +58,9 @@ cc.plistLoader = {
});
}
}
-cc.loader.register(["plist"], cc.plistLoader);
-/**
- * This is a loader to merge plist files to one file.
- */
-cc.pkgJsonLoader = {
- /**
- * @constant
- */
- KEY : {
- frames : "frames",
- rect : "rect", size : "size", offset : "offset", rotated : "rotated", aliases : "aliases",
+cc.loader.register(["plist"], cc._plistLoader);
- meta : "meta",
- image : "image"
- },
- /**
- * @constant
- */
- MIN_KEY : {
- frames : 0,
- rect : 0, size : 1, offset : 2, rotated : 3, aliases : 4,
-
- meta : 1,
- image : 0
- },
- _parse : function(data){
- var KEY = data instanceof Array ? this.MIN_KEY : this.KEY;
- var frames = {}, meta = data[KEY.meta] ? {image : data[KEY.meta][KEY.image]} : {};
- var tempFrames = data[KEY.frames];
- for (var frameName in tempFrames) {
- var f = tempFrames[frameName];
- var rect = f[KEY.rect];
- var size = f[KEY.size];
- var offset = f[KEY.offset];
- frames[frameName] = {
- rect : {x : rect[0], y : rect[1], width : rect[2], height : rect[3]},
- size : {width : size[0], height : size[1]},
- offset : {x : offset[0], y : offset[1]},
- rotated : f[KEY.rotated],
- aliases : f[KEY.aliases]
- }
- }
- return {_inited : true, frames : frames, meta : meta};
- },
- load : function(realUrl, url, res, cb){
- var self = this, locLoader = cc.loader, cache = locLoader.cache;
- locLoader.loadJson(realUrl, function(err, pkg){
- if(err) return cb(err);
- var dir = cc.path.dirname(url);
- for (var key in pkg) {
- var filePath = cc.path.join(dir, key);
- cache[filePath] = self._parse(pkg[key]);
- }
- cb(null, true);
- });
- }
-};
-cc.loader.register(["pkgJson"], cc.pkgJsonLoader);
-
-cc.fontLoader = {
+cc._fontLoader = {
TYPE : {
"eot" : "embedded-opentype",
"ttf" : "truetype",
@@ -164,9 +107,9 @@ cc.fontLoader = {
cb(null, true);
}
}
-cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc.fontLoader);
+cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader);
-cc.binaryLoader = {
+cc._binaryLoader = {
load : function(realUrl, url, res, cb){
cc.loader.loadBinary(realUrl, cb);
}
View
4 cocos2d/labels/CCLabelBMFont.js
@@ -1038,7 +1038,7 @@ cc.utf8_trim_from = function (str, index) {
-cc.fntLoader = {
+cc._fntLoader = {
INFO_EXP : /info [^\n]*(\n|$)/gi,
COMMON_EXP : /common [^\n]*(\n|$)/gi,
PAGE_EXP : /page [^\n]*(\n|$)/gi,
@@ -1124,4 +1124,4 @@ cc.fntLoader = {
});
}
};
-cc.loader.register(["fnt"], cc.fntLoader);
+cc.loader.register(["fnt"], cc._fntLoader);
View
2  cocos2d/tilemap/CCTMXXMLParser.js
@@ -930,4 +930,4 @@ cc.TMXMapInfo.create = function (tmxFile, resourcePath) {
};
-cc.loader.register(["tmx", "tsx"], cc.txtLoader);
+cc.loader.register(["tmx", "tsx"], cc._txtLoader);
View
2  extensions/ccb-reader/CCBReader.js
@@ -1123,4 +1123,4 @@ cc.BuilderReader.concat = function (stringA, stringB) {
return stringA + stringB;
};
-cc.loader.register(["ccbi"], cc.binaryLoader);
+cc.loader.register(["ccbi"], cc._binaryLoader);
Something went wrong with that request. Please try again.