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
};

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。