cocos3——2.js啓動 js_boot.js

【js語法相關】
遍歷對象或數組obj,執行函數context.iterator,函數返回false表示break
cc.each(obj, iterator, context)

從源對象拷貝所有屬性到目標對象,並返回目標對象
cc.extend(target, src0, src1..)

cc.isFunction(obj)
cc.isNumber(obj)
cc.isString(obj)
cc.isArray(obj)
cc.isUndefined(obj)
cc.isObject(obj)

定義原型的getter和setter,這樣就可用賦值的方式進行set函數的調用,更方便
cc.defineGetterSetter(proto, prop, getter, setter)

【async】
任務流程的控制
cc.async = {
	series : function (tasks, cb, target) {},
	parallel : function (tasks, cb, target) {},
	waterful : function (tasks, cb, target) {},
	map : function (tasks, cb, target) {},
	mapLimit : function (tasks, cb, target) {},
};

【path路徑操作】
cc.path = {
	join: function () {},				// 'a', 'b.png' -> 'a/b.png'
	extname: function (str) {},			//  -> '.png'; null
	basename: function (str, ext) {},	// 'a/b.png' -> 'b.png'; 'a/b.png','.png' -> 'b'
	dirname: function (str) {},			// 'a/b/c.png' -> 'a/b'
	changeExtname: function(str, ext) {}, // 'a/b.png','.plist' -> 'a/b.plist'
	changeBasename: function(str, base, sameExt) {}, // 'a/b.plist','c.plist' -> 'a/c.plist'; 'a/b.plist', 'c', true -> 'a/c.plist'
};

【loader加載器】
cc.loader = {
	getXMLHttpRequest(),
	loadJs(baseDir, jsList, cb),
	loadJsWithImg(baseDir, jsList, cb),
	loadTxt(url, cb),
	loadJson(url, cb),
	loadImg(url, option, cb),	// 加載一張圖片
	loadBinary(url, cb),
	loadBinarySync(url),
	
	_loadResIterator(item, index, cb),
	getUrl(basePath, url),
	load(resources, option, cb),	// 加載資源,然後回調
	loadAliases(url, cb),			// alias map
};

【字符串格式】
cc.formatStr()		// "a: %d, b: %b", a, b

【單例】
cc.director
cc.winSize
cc.view
cc.eventManager = cc.director.getEventDispatcher();
cc.audioEngine = cc.AudioEngine.getInstance();
cc.configuration = cc.Configuration.getInstance();

cc.textureCache = cc.director.getTextureCache();
cc.TextureCache.prototype.addImage = function(url, cb, target)
cc.shaderCache = cc.ShaderCache.getInstance();
cc.animationCache
cc.spriteFrameCache
cc.plistParser = cc.PlistParser.getInstance();
cc.fileUtils = cc.FileUtils.getInstance();

【jsb】
jsb.fileUtils = cc.fileUtils;
delete cc.FileUtils;
delete cc.fileUtils;

// only android
jsb.reflection = {
    callStaticMethod : function(){
        cc.log("not supported on current platform");
    }
};

【sys】
cc._initSys(config, CONFIG_KEY)

cc._initDebugSetting(mode)
// cc.error, cc.assert(cond, msg), cc.warn, cc.log

【game】
cc.game = {
	setFrameRate,
	restart,
	run,			// prepare -> onStart
	_initConfig,
	prepare			// 包含jsb.js及project.json裏的js
};

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章