diff --git a/.gitignore b/.gitignore index 63debf4ccd..73b9c1ae31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,10 @@ -# Ignore files build by WebStorm +lib +/web.config .idea +build +aspnet_client +node_modules +/tools/jsdoc_toolkit-2.4.0 +/package +/tools/jsdoc_toolkit/jsdoc_toolkit-2.4.0 +/.project diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 43af3292c4..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "samples"] - path = samples - url = https://github.com/cocos2d/cocos2d-js-tests.git diff --git a/AUTHORS.txt b/AUTHORS.txt index 6312a866c4..5a20dc7535 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -1,20 +1,20 @@ Cocos2d-html5 authors -(ordered by the join in time) +(Ordered by join time) Core Developers: Shun Lin (Sean Lin) - Hao Wu (WuHao) + Ricardo Quesada - Dingping Lv (David Lv) + Huabin LING (@pandamicro) - Shengxiang Chen (Nero Chan) + Sijie Wang (@VisualSJ) - Ricardo Quesada + Long Jiang (@jianglong0156) - Xingsen Ma + Menghe Zhang (@ZhangMenghe) Contributors: Name GithubID Main contribution @@ -22,6 +22,7 @@ Name GithubID Main contribution Dali Kilani @dadilcool added instruction to read me Chris @hannon235 added node.js api for box2d + added SocketIO and SocketIO tests Jason Aeschliman @jaeschliman fixed cc.Node setposition @@ -41,6 +42,7 @@ Mcscooter @mcscooter tilempapxml fixed Roed @roed Mouse rightclick api Mouse scroll fix for firefox + cc.Screen bug fix Surith Thekkiam(Zynga) @folecr match Cocos2dx api @@ -58,6 +60,7 @@ keisuke hata(Square) @Seasons7 Code review, bug fix Marat Yakupov @moadib Various bug fixes Liang Wu @akira-cn Touch location fix for designResolution + ScrollView on paused bugs fix Jimmy Sambuo @jsambuo AudioEngine improvements @@ -81,24 +84,205 @@ Kang-Hao Lu(Opera/Oupeng) @kennyluck Optimize John Resig's inheritance patter Mark Henderson @MarkEHenderson Code review, LabelTTF and Scale9Sprite bug fix Jing Wang @06wj CCScheduler improvements - Js file loading image add - cc.RectApplyAffineTransform improvements + Js file loading image add + cc.RectApplyAffineTransform improvements + Fixed a bug of cc.Node.setPosition that parameter check is incorrect Ze Wang @WanderWang Fix crash when BrowserTypes match nothing from navigator.userAgent LabelTTF improvements cc.TextureCache.dumpCachedTextureInfo 's bug fix + CCTween bug fix + CCScale9Sprite bug fix + sys.localStorage bug fix + CCArmature refactoring + cc.SpriteFrame and cc.SpriteFrameCache refactoring Christian Schwartz @cschwartz SpriteFrame.initWithTextureFilename converted fix XiaoJun Zheng @SmallAiTT _getResType error fix cc.ScrollView bug fix + cc.LabelTTF bug fix + rewrite functions in CCNS.js with regex + refactor CCScheduler.js and CCCommon.js + cc.BMFontConfiguration bug fix + refactor cc.Application to cc.game + refactor cc.loader + refactor cc.Textur2D + refactor some functions about array operation + move sys.xxx to cc.sys.xxx + refactor some public functions in cc to private + add node.js scripts for publishing game + refactor cc.CCBReader + cc.view bug fix + multiple property object supports in extend function Guozhu Cheng @bengol cc.SimpleAudioEngine bug fix Jing Xiao @xbruce cc.SAXParser bug fix + cc.ActionManager refactoring + cc.Scheduler refactoring + cc.LabelTTF refactoring + +JiaHui He @garfield_ho cc.FileUtils bug fix + cc.Builder and SpriteLoader bugs fix + CCBAnimation bug fix + +Luis Parravicini @luisparravicini cc.Director refactoring + cc.LabelTTF documentation + typo fix + +Jose Antonio @jandujar cc.ParticleSystem bug fix for CocoStudio animations + SceneReader bug fix + +BoHao Tang @btspoony cc.TableView bug fix + +Claudiu @csaftoiu cc.LabelTTF bug fix + cc.DrawNode bugs fix + cc.NodeRGBA bug fix + cc.Texture2D bug fix + +Pei Wu @rablwupei cc.ProgressTimer bug fix + cc.ParticleBatchNode bug fix + +kuaipao @kuaipao CocoStudio GUIReader bug fix + CocoStudio UIScrollView bug fix + CocoStudio UIWidget bug fix + +XieDaijin @NijiadeIX CCControl bug fix + +samael @samael65535 CCPhysicsSprite bug fix + +NatWeiss @NatWeiss Add analytics plugin protocol ,Flurry plugin and ProtocolAds.js plugin protocol + cc.FileUtils refactoring + cc.Audio bugs fix + cc.Texture2D bug fix + +Andor Salga @asalga typo fix + +erykwalder @erykwalder Function.prototype.bind bug fix + +ZippoLag @ZippoLag cc.Application.getCurrentLanguage bug fix + typo fix + Fixed `cc.TMXObjectGroup#objectNamed` not returning the result bug + +Asano @LaercioAsano cc.Node bug fix + +Bruno Assarisse @bassarisse cc.LabelBMFont bug fix + +Mykyta Usikov @musikov cc.ClippingNode bugs fix + cc.fontLoader bug fix + Inverted ClippingNode with DrawNode as stencil bug fix under canvas render mode + JumpTo bug with wrong _delta position bug fix + cc.ProgressTimer bugs fix + cc.Scale9Sprite bugs fix + cc.RenderTexture bug fix + cc.ParticleSystem bug fix + Made CCProgressTimerCanvasRenderCmd to properly show colorized sprites + cc.ScrollView and cc.TableView: added check for parent visibility in onTouchBegan method + +Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix + +AaronRZH @AaronRZH Creation of a sequence objcet or a spawn object by using new method bug fix + +Xiaodong Liu @tianxing113 cc.Spawn.create bug fix + ccui.LoadingBar.setPercent crash bug fix + +Park Hyun Chen @sincntx Touch anywhere of screen to finish input when using cc.EditBox + ccui.TextBMFont bug fix + cc.game bug fix + Fixed an issue of cc.ArmatureAnimation's setMovementEventCallFunc + +Ninja Lau @mutoo A typo bug in UILayout fix + One-loop CCArmatureAnimation can't finish when setSpeedScale is less than 1.0 bug fix + A transform error in CCTransformHelp.js fix + ccs.DisplayManager bug fix + Fix child armature lost _parentBone issue + cc.eventManager bug fix + ccs.Bone bug fix + ccs.ActionFrame bug fix + ccui.Widget bug fix + ccui.LoadingBar bug fix + +Taras Tovchenko @tovchenko cc.Skin bounding box calculation bug fix under canvas render mode + +Minh Quy @MQuy cc.MenuItemSprite bug fix + Check empty string for textureData + Adds type check functions + +Michael Yin @layerssss cc.game refactored + +Yang Yuchen @yycdef cc.sys bug fix + +K @kiwigrc cc.ParticleSystem bug fix + +Claudio Freitas @claudiofreitas ccui.TextField typo fix. + +nopakos @nopakos cc.Texture2D bug fix + +Robert Rouhani @Robmaister cc.TMXMapInfo bug fix + cc.TMXLayer bug fix + +Igor Mats @IgorMats cc.Scale9Sprite bug fix + Spine runtime update + Add getStroke and setStroke method to cc.MotionStreak + +Tim @duhaibo0404 ccs.csLoader bug fix + +Hermanto @man2 cc.loader bug fix + +Long Jiang @jianglong0156 cc.LabelBMFont bug fix + KeyCode bug fix + ccui.ListView bug fix + +Joe Lafiosca @lafiosca Added Javascript file loader + +galapagosit @galapagosit ccs.actionManager bug fix + +Dany Ellement @DEllement cc.FontDefinition & ccui.RichText improvements + cc.LayerGradient improvements + +IShm @IShm cc.Screen bug fix + cc.ParticleSystem bug fix + ccui.PageView bug fix + Fixed crash when character not found into BMP font + Fixed restoring of sprite's color issue + +Thomas Jablonski @thomas-jablonski cc.audioEngine bug fix + Cocostudio typo fix + +WingGao @WingGao cc.TMXLayer bug fix + +Skliar Ihor @igogo5yo Add Bower support + +feijing566 @feijing566 cc.Audio bug fix + +RackovychV @RackovychV Fixed a bug of `cc.Scheduler`'s `pauseAllTargetsWithMinPriority` + +giuseppelt @giuseppelt Fixed TransitionSlideX callback sequence issue + +YShumov @pixmaster Fixed issue in music end event + +SPACELAN @spacelan Fixed `inverse` function bug of `cc.math.Matrix4` + +patriciog @patriciog Allowed timeline animations with only one frame + +Ningxin Hu @huningxin SIMD.js optimization for kazmath functions + +Zachary Lester @ZLester Fix typo in AUTHORS.txt + +Juan Carlos @Ruluk Fixed a bug where not resetting cc.Audio._ignoreEnded when replaying a sound caused it to stay in a "playing" state + +Maxim Litvinov @metalim Throw new Error object instead of error message string + +Retired Core Developers: + Shengxiang Chen (Nero Chan) + Xingsen Ma + Jialong Zhai (@JoshuaAstray) + Hao Wu (WuHao) + Dingping Lv (David Lv) Cocos2d-x and cocos2d-html5 can not grow so fast without the active community. -Thanks to all developers who report & trace bugs, dicuss the engine usage in forum & QQ groups! +Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups! Special thanks to Ricardo Quesada for giving us lots of guidances & suggestions. diff --git a/Base64Images.js b/Base64Images.js new file mode 100644 index 0000000000..0d983506be --- /dev/null +++ b/Base64Images.js @@ -0,0 +1,32 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +var cc = cc || {}; + +cc._loadingImage = "data:image/gif;base64,R0lGODlhEAAQALMNAD8/P7+/vyoqKlVVVX9/fxUVFUBAQGBgYMDAwC8vL5CQkP///wAAAP///wAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAANACwAAAAAEAAQAAAEO5DJSau9OOvNex0IMnDIsiCkiW6g6BmKYlBFkhSUEgQKlQCARG6nEBwOgl+QApMdCIRD7YZ5RjlGpCUCACH5BAUAAA0ALAAAAgAOAA4AAAQ6kLGB0JA4M7QW0hrngRllkYyhKAYqKUGguAws0ypLS8JxCLQDgXAIDg+FRKIA6v0SAECC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JcxTMb+OW6uY9mGHrCzDQwwAbTp2uKuTZ9N1uYsfRRR8WPhrm419mSSjRyiqxVK7y23B/ftuTm2oSdJyzNVw3BFn7vTlbnqF9dS2fu9OVueon11lZuQ2iLdsGFD05H2dNQGV0ntG5Tz1dWm9N1b2kVq8EVwsI2UaQaQOKhmitZGLOmk68DhSFvY+gfWNSAg7z3Qvo7yKCKIohiaNR5LKxx8qpxvjcqS0VpbxvwOAcRQPZ7D0G9Y0uz2HoH1jUCpLY7zXlpbm3eKO5QuzjrBqZji3x17PvNcyT288VvDBJbMWUovS2hslW7mFQ9nsPQPrGl2ew9A+saCod/WNxtbYsrfb17WBxx5ddD2281xC88klvDcSXEnWuzrqOGGC9zRUPZ7D0G9Y0uzWHoH1jQVCLreq6ntZbaO3it1mGy7RjTs1X2mYy20ZiCq8ZOODcdEdmsPQb1jS7PYegfWNdJuLqnQiSUlRqpFLmryxtH1Ma7Qw2gNNPOdSt0oI27p007s9h6B9Y0uz2HoH1jXX3Z+I4+1b8IJdX89xLHKQFMXQUahpxoiPN5P+onfU+A0/s9h6DesaXZ7D0D6xpG7OLbUtu0StW5JJx2bBsmbtiSiEk+cxoCWWSaVpZOk2vDVo0VYdnsPQb1jSNvZcCH1jSd2c+p1XAmFqEOmOPEfaH+BQd1ueo211IzrgFUYKNAAqI1WztCpUqVCRUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoD/9k="; diff --git a/CCBoot.js b/CCBoot.js new file mode 100644 index 0000000000..22c50494b6 --- /dev/null +++ b/CCBoot.js @@ -0,0 +1,2899 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2015 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace + * @namespace + * @name cc + */ +var cc = cc || {}; +cc._tmp = cc._tmp || {}; +cc._LogInfos = {}; + +var _p = window; +/** @expose */ +_p.gl; +/** @expose */ +_p.WebGLRenderingContext; +/** @expose */ +_p.DeviceOrientationEvent; +/** @expose */ +_p.DeviceMotionEvent; +/** @expose */ +_p.AudioContext; +if (!_p.AudioContext) { + /** @expose */ + _p.webkitAudioContext; +} +/** @expose */ +_p.mozAudioContext; +_p = Object.prototype; +/** @expose */ +_p._super; +/** @expose */ +_p.ctor; +_p = null; + +/** + * drawing primitive of game engine + * @type {cc.DrawingPrimitive} + */ +cc._drawingUtil = null; + +/** + * main Canvas 2D/3D Context of game engine + * @type {CanvasRenderingContext2D|WebGLRenderingContext} + */ +cc._renderContext = null; +cc._supportRender = false; + +/** + * Main canvas of game engine + * @type {HTMLCanvasElement} + */ +cc._canvas = null; + +/** + * The element contains the game canvas + * @type {HTMLDivElement} + */ +cc.container = null; +cc._gameDiv = null; + +window.ENABLE_IMAEG_POOL = true; + +/** + * Iterate over an object or an array, executing a function for each matched element. + * @param {object|array} obj + * @param {function} iterator + * @param {object} [context] + */ +cc.each = function (obj, iterator, context) { + if (!obj) + return; + if (obj instanceof Array) { + for (var i = 0, li = obj.length; i < li; i++) { + if (iterator.call(context, obj[i], i) === false) + return; + } + } else { + for (var key in obj) { + if (iterator.call(context, obj[key], key) === false) + return; + } + } +}; + +/** + * Copy all of the properties in source objects to target object and return the target object. + * @param {object} target + * @param {object} *sources + * @returns {object} + */ +cc.extend = function (target) { + var sources = arguments.length >= 2 ? Array.prototype.slice.call(arguments, 1) : []; + + cc.each(sources, function (src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }); + return target; +}; + +/** + * Another way to subclass: Using Google Closure. + * The following code was copied + pasted from goog.base / goog.inherits + * @function + * @param {Function} childCtor + * @param {Function} parentCtor + */ +cc.inherits = function (childCtor, parentCtor) { + function tempCtor() {} + tempCtor.prototype = parentCtor.prototype; + childCtor.superClass_ = parentCtor.prototype; + childCtor.prototype = new tempCtor(); + childCtor.prototype.constructor = childCtor; + + // Copy "static" method, but doesn't generate subclasses. + // for( var i in parentCtor ) { + // childCtor[ i ] = parentCtor[ i ]; + // } +}; + +/** + * Check the obj whether is function or not + * @param {*} obj + * @returns {boolean} + */ +cc.isFunction = function (obj) { + return typeof obj === 'function'; +}; + +/** + * Check the obj whether is number or not + * @param {*} obj + * @returns {boolean} + */ +cc.isNumber = function (obj) { + return typeof obj === 'number' || Object.prototype.toString.call(obj) === '[object Number]'; +}; + +/** + * Check the obj whether is string or not + * @param {*} obj + * @returns {boolean} + */ +cc.isString = function (obj) { + return typeof obj === 'string' || Object.prototype.toString.call(obj) === '[object String]'; +}; + +/** + * Check the obj whether is array or not + * @param {*} obj + * @returns {boolean} + */ +cc.isArray = function (obj) { + return Array.isArray(obj) || + (typeof obj === 'object' && Object.prototype.toString.call(obj) === '[object Array]'); +}; + +/** + * Check the obj whether is undefined or not + * @param {*} obj + * @returns {boolean} + */ +cc.isUndefined = function (obj) { + return typeof obj === 'undefined'; +}; + +/** + * Check the obj whether is object or not + * @param {*} obj + * @returns {boolean} + */ +cc.isObject = function (obj) { + return typeof obj === "object" && Object.prototype.toString.call(obj) === '[object Object]'; +}; + +/** + * Check the url whether cross origin + * @param {String} url + * @returns {boolean} + */ +cc.isCrossOrigin = function (url) { + if (!url) { + cc.log("invalid URL"); + return false; + } + var startIndex = url.indexOf("://"); + if (startIndex === -1) + return false; + + var endIndex = url.indexOf("/", startIndex + 3); + var urlOrigin = (endIndex === -1) ? url : url.substring(0, endIndex); + return urlOrigin !== location.origin; +}; + +//+++++++++++++++++++++++++something about async begin+++++++++++++++++++++++++++++++ +/** + * Async Pool class, a helper of cc.async + * @param {Object|Array} srcObj + * @param {Number} limit the limit of parallel number + * @param {function} iterator + * @param {function} onEnd + * @param {object} target + * @constructor + */ +cc.AsyncPool = function (srcObj, limit, iterator, onEnd, target) { + var self = this; + self._finished = false; + self._srcObj = srcObj; + self._limit = limit; + self._pool = []; + self._iterator = iterator; + self._iteratorTarget = target; + self._onEnd = onEnd; + self._onEndTarget = target; + self._results = srcObj instanceof Array ? [] : {}; + self._errors = srcObj instanceof Array ? [] : {}; + + cc.each(srcObj, function (value, index) { + self._pool.push({index: index, value: value}); + }); + + self.size = self._pool.length; + self.finishedSize = 0; + self._workingSize = 0; + + self._limit = self._limit || self.size; + + self.onIterator = function (iterator, target) { + self._iterator = iterator; + self._iteratorTarget = target; + }; + + self.onEnd = function (endCb, endCbTarget) { + self._onEnd = endCb; + self._onEndTarget = endCbTarget; + }; + + self._handleItem = function () { + var self = this; + if (self._pool.length === 0 || self._workingSize >= self._limit) + return; //return directly if the array's length = 0 or the working size great equal limit number + + var item = self._pool.shift(); + var value = item.value, index = item.index; + self._workingSize++; + self._iterator.call(self._iteratorTarget, value, index, + function (err, result) { + if (self._finished) { + return; + } + + if (err) { + self._errors[this.index] = err; + } + else { + self._results[this.index] = result; + } + + self.finishedSize++; + self._workingSize--; + if (self.finishedSize === self.size) { + var errors = self._errors.length === 0 ? null : self._errors; + self.onEnd(errors, self._results); + return; + } + self._handleItem(); + }.bind(item), + self); + }; + + self.flow = function () { + var self = this; + if (self._pool.length === 0) { + if (self._onEnd) + self._onEnd.call(self._onEndTarget, null, []); + return; + } + for (var i = 0; i < self._limit; i++) + self._handleItem(); + }; + + self.onEnd = function(errors, results) { + self._finished = true; + if (self._onEnd) { + var selector = self._onEnd; + var target = self._onEndTarget; + self._onEnd = null; + self._onEndTarget = null; + selector.call(target, errors, results); + } + }; +}; + +/** + * @class + */ +cc.async = /** @lends cc.async# */{ + /** + * Do tasks series. + * @param {Array|Object} tasks + * @param {function} [cb] callback + * @param {Object} [target] + * @return {cc.AsyncPool} + */ + series: function (tasks, cb, target) { + var asyncPool = new cc.AsyncPool(tasks, 1, function (func, index, cb1) { + func.call(target, cb1); + }, cb, target); + asyncPool.flow(); + return asyncPool; + }, + + /** + * Do tasks parallel. + * @param {Array|Object} tasks + * @param {function} cb callback + * @param {Object} [target] + * @return {cc.AsyncPool} + */ + parallel: function (tasks, cb, target) { + var asyncPool = new cc.AsyncPool(tasks, 0, function (func, index, cb1) { + func.call(target, cb1); + }, cb, target); + asyncPool.flow(); + return asyncPool; + }, + + /** + * Do tasks waterfall. + * @param {Array|Object} tasks + * @param {function} cb callback + * @param {Object} [target] + * @return {cc.AsyncPool} + */ + waterfall: function (tasks, cb, target) { + var args = []; + var lastResults = [null];//the array to store the last results + var asyncPool = new cc.AsyncPool(tasks, 1, + function (func, index, cb1) { + args.push(function (err) { + args = Array.prototype.slice.call(arguments, 1); + if (tasks.length - 1 === index) lastResults = lastResults.concat(args);//while the last task + cb1.apply(null, arguments); + }); + func.apply(target, args); + }, function (err) { + if (!cb) + return; + if (err) + return cb.call(target, err); + cb.apply(target, lastResults); + }); + asyncPool.flow(); + return asyncPool; + }, + + /** + * Do tasks by iterator. + * @param {Array|Object} tasks + * @param {function|Object} iterator + * @param {function} [callback] + * @param {Object} [target] + * @return {cc.AsyncPool} + */ + map: function (tasks, iterator, callback, target) { + var locIterator = iterator; + if (typeof(iterator) === "object") { + callback = iterator.cb; + target = iterator.iteratorTarget; + locIterator = iterator.iterator; + } + var asyncPool = new cc.AsyncPool(tasks, 0, locIterator, callback, target); + asyncPool.flow(); + return asyncPool; + }, + + /** + * Do tasks by iterator limit. + * @param {Array|Object} tasks + * @param {Number} limit + * @param {function} iterator + * @param {function} cb callback + * @param {Object} [target] + */ + mapLimit: function (tasks, limit, iterator, cb, target) { + var asyncPool = new cc.AsyncPool(tasks, limit, iterator, cb, target); + asyncPool.flow(); + return asyncPool; + } +}; +//+++++++++++++++++++++++++something about async end+++++++++++++++++++++++++++++++++ + +//+++++++++++++++++++++++++something about path begin++++++++++++++++++++++++++++++++ +/** + * @class + */ +cc.path = /** @lends cc.path# */{ + normalizeRE: /[^\.\/]+\/\.\.\//, + + /** + * Join strings to be a path. + * @example + cc.path.join("a", "b.png");//-->"a/b.png" + cc.path.join("a", "b", "c.png");//-->"a/b/c.png" + cc.path.join("a", "b");//-->"a/b" + cc.path.join("a", "b", "/");//-->"a/b/" + cc.path.join("a", "b/", "/");//-->"a/b/" + * @returns {string} + */ + join: function () { + var l = arguments.length; + var result = ""; + for (var i = 0; i < l; i++) { + result = (result + (result === "" ? "" : "/") + arguments[i]).replace(/(\/|\\\\)$/, ""); + } + return result; + }, + + /** + * Get the ext name of a path. + * @example + cc.path.extname("a/b.png");//-->".png" + cc.path.extname("a/b.png?a=1&b=2");//-->".png" + cc.path.extname("a/b");//-->null + cc.path.extname("a/b?a=1&b=2");//-->null + * @param {string} pathStr + * @returns {*} + */ + extname: function (pathStr) { + var temp = /(\.[^\.\/\?\\]*)(\?.*)?$/.exec(pathStr); + return temp ? temp[1] : null; + }, + + /** + * Get the main name of a file name + * @param {string} fileName + * @returns {string} + */ + mainFileName: function (fileName) { + if (fileName) { + var idx = fileName.lastIndexOf("."); + if (idx !== -1) + return fileName.substring(0, idx); + } + return fileName; + }, + + /** + * Get the file name of a file path. + * @example + cc.path.basename("a/b.png");//-->"b.png" + cc.path.basename("a/b.png?a=1&b=2");//-->"b.png" + cc.path.basename("a/b.png", ".png");//-->"b" + cc.path.basename("a/b.png?a=1&b=2", ".png");//-->"b" + cc.path.basename("a/b.png", ".txt");//-->"b.png" + * @param {string} pathStr + * @param {string} [extname] + * @returns {*} + */ + basename: function (pathStr, extname) { + var index = pathStr.indexOf("?"); + if (index > 0) pathStr = pathStr.substring(0, index); + var reg = /(\/|\\\\)([^(\/|\\\\)]+)$/g; + var result = reg.exec(pathStr.replace(/(\/|\\\\)$/, "")); + if (!result) return null; + var baseName = result[2]; + if (extname && pathStr.substring(pathStr.length - extname.length).toLowerCase() === extname.toLowerCase()) + return baseName.substring(0, baseName.length - extname.length); + return baseName; + }, + + /** + * Get dirname of a file path. + * @example + * unix + cc.path.driname("a/b/c.png");//-->"a/b" + cc.path.driname("a/b/c.png?a=1&b=2");//-->"a/b" + cc.path.dirname("a/b/");//-->"a/b" + cc.path.dirname("c.png");//-->"" + * windows + cc.path.driname("a\\b\\c.png");//-->"a\b" + cc.path.driname("a\\b\\c.png?a=1&b=2");//-->"a\b" + * @param {string} pathStr + * @returns {*} + */ + dirname: function (pathStr) { + return pathStr.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/, '$2'); + }, + + /** + * Change extname of a file path. + * @example + cc.path.changeExtname("a/b.png", ".plist");//-->"a/b.plist" + cc.path.changeExtname("a/b.png?a=1&b=2", ".plist");//-->"a/b.plist?a=1&b=2" + * @param {string} pathStr + * @param {string} [extname] + * @returns {string} + */ + changeExtname: function (pathStr, extname) { + extname = extname || ""; + var index = pathStr.indexOf("?"); + var tempStr = ""; + if (index > 0) { + tempStr = pathStr.substring(index); + pathStr = pathStr.substring(0, index); + } + index = pathStr.lastIndexOf("."); + if (index < 0) return pathStr + extname + tempStr; + return pathStr.substring(0, index) + extname + tempStr; + }, + /** + * Change file name of a file path. + * @example + cc.path.changeBasename("a/b/c.plist", "b.plist");//-->"a/b/b.plist" + cc.path.changeBasename("a/b/c.plist?a=1&b=2", "b.plist");//-->"a/b/b.plist?a=1&b=2" + cc.path.changeBasename("a/b/c.plist", ".png");//-->"a/b/c.png" + cc.path.changeBasename("a/b/c.plist", "b");//-->"a/b/b" + cc.path.changeBasename("a/b/c.plist", "b", true);//-->"a/b/b.plist" + * @param {String} pathStr + * @param {String} basename + * @param {Boolean} [isSameExt] + * @returns {string} + */ + changeBasename: function (pathStr, basename, isSameExt) { + if (basename.indexOf(".") === 0) return this.changeExtname(pathStr, basename); + var index = pathStr.indexOf("?"); + var tempStr = ""; + var ext = isSameExt ? this.extname(pathStr) : ""; + if (index > 0) { + tempStr = pathStr.substring(index); + pathStr = pathStr.substring(0, index); + } + index = pathStr.lastIndexOf("/"); + index = index <= 0 ? 0 : index + 1; + return pathStr.substring(0, index) + basename + ext + tempStr; + }, + //todo make public after verification + _normalize: function (url) { + var oldUrl = url = String(url); + + //removing all ../ + do { + oldUrl = url; + url = url.replace(this.normalizeRE, ""); + } while (oldUrl.length !== url.length); + return url; + } +}; +//+++++++++++++++++++++++++something about path end++++++++++++++++++++++++++++++++ + +//+++++++++++++++++++++++++something about loader start+++++++++++++++++++++++++++ +/** + * Resource loading management. Created by in CCBoot.js as a singleton + * cc.loader. + * @name cc.Loader + * @class + * @memberof cc + * @see cc.loader + */ + +var imagePool = { + _pool: new Array(10), + _MAX: 10, + _smallImg: "data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=", + + count: 0, + get: function () { + if (this.count > 0) { + this.count--; + var result = this._pool[this.count]; + this._pool[this.count] = null; + return result; + } + else { + return new Image(); + } + }, + put: function (img) { + var pool = this._pool; + if (img instanceof HTMLImageElement && this.count < this._MAX) { + img.src = this._smallImg; + pool[this.count] = img; + this.count++; + } + } +}; + +/** + * Singleton instance of cc.Loader. + * @name cc.loader + * @member {cc.Loader} + * @memberof cc + */ +cc.loader = (function () { + var _jsCache = {}, //cache for js + _register = {}, //register of loaders + _langPathCache = {}, //cache for lang path + _aliases = {}, //aliases for res url + _queue = {}, // Callback queue for resources already loading + _urlRegExp = new RegExp("^(?:https?|ftp)://\\S*$", "i"); + + return /** @lends cc.Loader# */{ + /** + * Root path of resources. + * @type {String} + */ + resPath: "", + + /** + * Root path of audio resources + * @type {String} + */ + audioPath: "", + + /** + * Cache for data loaded. + * @type {Object} + */ + cache: {}, + + /** + * Get XMLHttpRequest. + * @returns {XMLHttpRequest} + */ + getXMLHttpRequest: function () { + var xhr = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP"); + xhr.timeout = 10000; + if (xhr.ontimeout === undefined) { + xhr._timeoutId = -1; + } + return xhr; + }, + + //@MODE_BEGIN DEV + + _getArgs4Js: function (args) { + var a0 = args[0], a1 = args[1], a2 = args[2], results = ["", null, null]; + + if (args.length === 1) { + results[1] = a0 instanceof Array ? a0 : [a0]; + } else if (args.length === 2) { + if (typeof a1 === "function") { + results[1] = a0 instanceof Array ? a0 : [a0]; + results[2] = a1; + } else { + results[0] = a0 || ""; + results[1] = a1 instanceof Array ? a1 : [a1]; + } + } else if (args.length === 3) { + results[0] = a0 || ""; + results[1] = a1 instanceof Array ? a1 : [a1]; + results[2] = a2; + } else throw new Error("arguments error to load js!"); + return results; + }, + + isLoading: function (url) { + return (_queue[url] !== undefined); + }, + + /** + * Load js files. + * If the third parameter doesn't exist, then the baseDir turns to be "". + * + * @param {string} [baseDir] The pre path for jsList or the list of js path. + * @param {array} jsList List of js path. + * @param {function} [cb] Callback function + * @returns {*} + */ + loadJs: function (baseDir, jsList, cb) { + var self = this, + args = self._getArgs4Js(arguments); + + var preDir = args[0], list = args[1], callback = args[2]; + if (navigator.userAgent.indexOf("Trident/5") > -1) { + self._loadJs4Dependency(preDir, list, 0, callback); + } else { + cc.async.map(list, function (item, index, cb1) { + var jsPath = cc.path.join(preDir, item); + if (_jsCache[jsPath]) return cb1(null); + self._createScript(jsPath, false, cb1); + }, callback); + } + }, + /** + * Load js width loading image. + * + * @param {string} [baseDir] + * @param {array} jsList + * @param {function} [cb] + */ + loadJsWithImg: function (baseDir, jsList, cb) { + var self = this, jsLoadingImg = self._loadJsImg(), + args = self._getArgs4Js(arguments); + this.loadJs(args[0], args[1], function (err) { + if (err) throw new Error(err); + jsLoadingImg.parentNode.removeChild(jsLoadingImg);//remove loading gif + if (args[2]) args[2](); + }); + }, + _createScript: function (jsPath, isAsync, cb) { + var d = document, self = this, s = document.createElement('script'); + s.async = isAsync; + _jsCache[jsPath] = true; + if (cc.game.config["noCache"] && typeof jsPath === "string") { + if (self._noCacheRex.test(jsPath)) + s.src = jsPath + "&_t=" + (new Date() - 0); + else + s.src = jsPath + "?_t=" + (new Date() - 0); + } else { + s.src = jsPath; + } + s.addEventListener('load', function () { + s.parentNode.removeChild(s); + this.removeEventListener('load', arguments.callee, false); + cb(); + }, false); + s.addEventListener('error', function () { + s.parentNode.removeChild(s); + cb("Load " + jsPath + " failed!"); + }, false); + d.body.appendChild(s); + }, + _loadJs4Dependency: function (baseDir, jsList, index, cb) { + if (index >= jsList.length) { + if (cb) cb(); + return; + } + var self = this; + self._createScript(cc.path.join(baseDir, jsList[index]), false, function (err) { + if (err) return cb(err); + self._loadJs4Dependency(baseDir, jsList, index + 1, cb); + }); + }, + _loadJsImg: function () { + var d = document, jsLoadingImg = d.getElementById("cocos2d_loadJsImg"); + if (!jsLoadingImg) { + jsLoadingImg = document.createElement('img'); + + if (cc._loadingImage) + jsLoadingImg.src = cc._loadingImage; + + var canvasNode = d.getElementById(cc.game.config["id"]); + canvasNode.style.backgroundColor = "transparent"; + canvasNode.parentNode.appendChild(jsLoadingImg); + + var canvasStyle = getComputedStyle ? getComputedStyle(canvasNode) : canvasNode.currentStyle; + if (!canvasStyle) + canvasStyle = {width: canvasNode.width, height: canvasNode.height}; + jsLoadingImg.style.left = canvasNode.offsetLeft + (parseFloat(canvasStyle.width) - jsLoadingImg.width) / 2 + "px"; + jsLoadingImg.style.top = canvasNode.offsetTop + (parseFloat(canvasStyle.height) - jsLoadingImg.height) / 2 + "px"; + jsLoadingImg.style.position = "absolute"; + } + return jsLoadingImg; + }, + //@MODE_END DEV + + /** + * Load a single resource as txt. + * @param {string} url + * @param {function} [cb] arguments are : err, txt + */ + loadTxt: function (url, cb) { + if (!cc._isNodeJs) { + var xhr = this.getXMLHttpRequest(), + errInfo = "load " + url + " failed!"; + xhr.open("GET", url, true); + if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { + // IE-specific logic here + xhr.setRequestHeader("Accept-Charset", "utf-8"); + xhr.onreadystatechange = function () { + if (xhr.readyState === 4) + (xhr.status === 200||xhr.status === 0) ? cb(null, xhr.responseText) : cb({status:xhr.status, errorMessage:errInfo}, null); + }; + } else { + if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8"); + var loadCallback = function () { + xhr.removeEventListener('load', loadCallback); + xhr.removeEventListener('error', errorCallback); + if (xhr._timeoutId >= 0) { + clearTimeout(xhr._timeoutId); + } + else { + xhr.removeEventListener('timeout', timeoutCallback); + } + if (xhr.readyState === 4) { + (xhr.status === 200||xhr.status === 0) ? cb(null, xhr.responseText) : cb({status:xhr.status, errorMessage:errInfo}, null); + } + }; + var errorCallback = function () { + xhr.removeEventListener('load', loadCallback); + xhr.removeEventListener('error', errorCallback); + if (xhr._timeoutId >= 0) { + clearTimeout(xhr._timeoutId); + } + else { + xhr.removeEventListener('timeout', timeoutCallback); + } + cb({status: xhr.status, errorMessage: errInfo}, null); + }; + var timeoutCallback = function () { + xhr.removeEventListener('load', loadCallback); + xhr.removeEventListener('error', errorCallback); + if (xhr._timeoutId >= 0) { + clearTimeout(xhr._timeoutId); + } + else { + xhr.removeEventListener('timeout', timeoutCallback); + } + cb({status: xhr.status, errorMessage: "Request timeout: " + errInfo}, null); + }; + xhr.addEventListener('load', loadCallback); + xhr.addEventListener('error', errorCallback); + if (xhr.ontimeout === undefined) { + xhr._timeoutId = setTimeout(function () { + timeoutCallback(); + }, xhr.timeout); + } + else { + xhr.addEventListener('timeout', timeoutCallback); + } + } + xhr.send(null); + } else { + var fs = require("fs"); + fs.readFile(url, function (err, data) { + err ? cb(err) : cb(null, data.toString()); + }); + } + }, + + loadCsb: function(url, cb){ + var xhr = cc.loader.getXMLHttpRequest(), + errInfo = "load " + url + " failed!"; + xhr.open("GET", url, true); + xhr.responseType = "arraybuffer"; + + var loadCallback = function () { + xhr.removeEventListener('load', loadCallback); + xhr.removeEventListener('error', errorCallback); + if (xhr._timeoutId >= 0) { + clearTimeout(xhr._timeoutId); + } + else { + xhr.removeEventListener('timeout', timeoutCallback); + } + var arrayBuffer = xhr.response; // Note: not oReq.responseText + if (arrayBuffer) { + window.msg = arrayBuffer; + } + if (xhr.readyState === 4) { + (xhr.status === 200||xhr.status === 0) ? cb(null, xhr.response) : cb({status:xhr.status, errorMessage:errInfo}, null); + } + }; + var errorCallback = function(){ + xhr.removeEventListener('load', loadCallback); + xhr.removeEventListener('error', errorCallback); + if (xhr._timeoutId >= 0) { + clearTimeout(xhr._timeoutId); + } + else { + xhr.removeEventListener('timeout', timeoutCallback); + } + cb({status:xhr.status, errorMessage:errInfo}, null); + }; + var timeoutCallback = function () { + xhr.removeEventListener('load', loadCallback); + xhr.removeEventListener('error', errorCallback); + if (xhr._timeoutId >= 0) { + clearTimeout(xhr._timeoutId); + } + else { + xhr.removeEventListener('timeout', timeoutCallback); + } + cb({status: xhr.status, errorMessage: "Request timeout: " + errInfo}, null); + }; + xhr.addEventListener('load', loadCallback); + xhr.addEventListener('error', errorCallback); + if (xhr.ontimeout === undefined) { + xhr._timeoutId = setTimeout(function () { + timeoutCallback(); + }, xhr.timeout); + } + else { + xhr.addEventListener('timeout', timeoutCallback); + } + xhr.send(null); + }, + + /** + * Load a single resource as json. + * @param {string} url + * @param {function} [cb] arguments are : err, json + */ + loadJson: function (url, cb) { + this.loadTxt(url, function (err, txt) { + if (err) { + cb(err); + } + else { + try { + var result = JSON.parse(txt); + } + catch (e) { + throw new Error("parse json [" + url + "] failed : " + e); + return; + } + cb(null, result); + } + }); + }, + + _checkIsImageURL: function (url) { + var ext = /(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(url); + return (ext != null); + }, + /** + * Load a single image. + * @param {!string} url + * @param {object} [option] + * @param {function} callback + * @returns {Image} + */ + loadImg: function (url, option, callback, img) { + var opt = { + isCrossOrigin: true + }; + if (callback !== undefined) + opt.isCrossOrigin = option.isCrossOrigin === undefined ? opt.isCrossOrigin : option.isCrossOrigin; + else if (option !== undefined) + callback = option; + + var texture = this.getRes(url); + if (texture) { + callback && callback(null, texture); + return null; + } + + var queue = _queue[url]; + if (queue) { + queue.callbacks.push(callback); + return queue.img; + } + + img = img || imagePool.get(); + if (opt.isCrossOrigin && location.origin !== "file://") + img.crossOrigin = "Anonymous"; + else + img.crossOrigin = null; + + var loadCallback = function () { + this.removeEventListener('load', loadCallback, false); + this.removeEventListener('error', errorCallback, false); + + var queue = _queue[url]; + if (queue) { + var callbacks = queue.callbacks; + for (var i = 0; i < callbacks.length; ++i) { + var cb = callbacks[i]; + if (cb) { + cb(null, img); + } + } + queue.img = null; + delete _queue[url]; + } + + if (window.ENABLE_IMAEG_POOL && cc._renderType === cc.game.RENDER_TYPE_WEBGL) { + imagePool.put(img); + } + }; + + var self = this; + var errorCallback = function () { + this.removeEventListener('load', loadCallback, false); + this.removeEventListener('error', errorCallback, false); + + if (window.location.protocol !== 'https:' && img.crossOrigin && img.crossOrigin.toLowerCase() === "anonymous") { + opt.isCrossOrigin = false; + self.release(url); + cc.loader.loadImg(url, opt, callback, img); + } else { + var queue = _queue[url]; + if (queue) { + var callbacks = queue.callbacks; + for (var i = 0; i < callbacks.length; ++i) { + var cb = callbacks[i]; + if (cb) { + cb("load image failed"); + } + } + queue.img = null; + delete _queue[url]; + } + + if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) { + imagePool.put(img); + } + } + }; + + _queue[url] = { + img: img, + callbacks: callback ? [callback] : [] + }; + + img.addEventListener("load", loadCallback); + img.addEventListener("error", errorCallback); + img.src = url; + return img; + }, + + /** + * Iterator function to load res + * @param {object} item + * @param {number} index + * @param {function} [cb] + * @returns {*} + * @private + */ + _loadResIterator: function (item, index, cb) { + var self = this, url = null; + var type = item.type; + if (type) { + type = "." + type.toLowerCase(); + url = item.src ? item.src : item.name + type; + } else { + url = item; + type = cc.path.extname(url); + } + + var obj = self.getRes(url); + if (obj) + return cb(null, obj); + var loader = null; + if (type) { + loader = _register[type.toLowerCase()]; + } + if (!loader) { + cc.error("loader for [" + type + "] doesn't exist!"); + return cb(); + } + var realUrl = url; + if (!_urlRegExp.test(url)) { + var basePath = loader.getBasePath ? loader.getBasePath() : self.resPath; + realUrl = self.getUrl(basePath, url); + } + + if (cc.game.config["noCache"] && typeof realUrl === "string") { + if (self._noCacheRex.test(realUrl)) + realUrl += "&_t=" + (new Date() - 0); + else + realUrl += "?_t=" + (new Date() - 0); + } + loader.load(realUrl, url, item, function (err, data) { + if (err) { + cc.log(err); + self.cache[url] = null; + delete self.cache[url]; + cb({status: 520, errorMessage: err}, null); + } else { + self.cache[url] = data; + cb(null, data); + } + }); + }, + _noCacheRex: /\?/, + + /** + * Get url with basePath. + * @param {string} basePath + * @param {string} [url] + * @returns {*} + */ + getUrl: function (basePath, url) { + var self = this, path = cc.path; + if (basePath !== undefined && url === undefined) { + url = basePath; + var type = path.extname(url); + type = type ? type.toLowerCase() : ""; + var loader = _register[type]; + if (!loader) + basePath = self.resPath; + else + basePath = loader.getBasePath ? loader.getBasePath() : self.resPath; + } + url = cc.path.join(basePath || "", url); + 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.sys.language + extname; + } + return url; + }, + + /** + * Load resources then call the callback. + * @param {string} resources + * @param {function} [option] callback or trigger + * @param {function|Object} [loadCallback] + * @return {cc.AsyncPool} + */ + load: function (resources, option, loadCallback) { + var self = this; + var len = arguments.length; + if (len === 0) + throw new Error("arguments error!"); + + if (len === 3) { + if (typeof option === "function") { + if (typeof loadCallback === "function") + option = {trigger: option, cb: loadCallback}; + else + option = {cb: option, cbTarget: loadCallback}; + } + } else if (len === 2) { + if (typeof option === "function") + option = {cb: option}; + } else if (len === 1) { + option = {}; + } + + if (!(resources instanceof Array)) + resources = [resources]; + var asyncPool = new cc.AsyncPool( + resources, cc.CONCURRENCY_HTTP_REQUEST_COUNT, + function (value, index, AsyncPoolCallback, aPool) { + self._loadResIterator(value, index, function (err) { + var arr = Array.prototype.slice.call(arguments, 1); + if (option.trigger) + option.trigger.call(option.triggerTarget, arr[0], aPool.size, aPool.finishedSize); //call trigger + AsyncPoolCallback(err, arr[0]); + }); + }, + option.cb, option.cbTarget); + asyncPool.flow(); + return asyncPool; + }, + + _handleAliases: function (fileNames, cb) { + var self = this; + var resList = []; + for (var key in fileNames) { + var value = fileNames[key]; + _aliases[key] = value; + resList.push(value); + } + this.load(resList, cb); + }, + + /** + *

+ * Loads alias map from the contents of a filename.
+ *
+ * @note The plist file name should follow the format below:
+ *
+ *
+ *
+ *
+ * filenames
+ *
+ * sounds/click.wav
+ * sounds/click.caf
+ * sounds/endgame.wav
+ * sounds/endgame.caf
+ * sounds/gem-0.wav
+ * sounds/gem-0.caf
+ *

+ * metadata
+ *
+ * version
+ * 1
+ *

+ *

+ *

+ *

+ * @param {String} url The plist file name. + * @param {Function} [callback] + */ + loadAliases: function (url, callback) { + var self = this, dict = self.getRes(url); + if (!dict) { + self.load(url, function (err, results) { + self._handleAliases(results[0]["filenames"], callback); + }); + } else + self._handleAliases(dict["filenames"], callback); + }, + + /** + * Register a resource loader into loader. + * @param {string} extNames + * @param {function} loader + */ + register: function (extNames, loader) { + if (!extNames || !loader) return; + var self = this; + if (typeof extNames === "string") + return _register[extNames.trim().toLowerCase()] = loader; + for (var i = 0, li = extNames.length; i < li; i++) { + _register["." + extNames[i].trim().toLowerCase()] = loader; + } + }, + + /** + * Get resource data by url. + * @param url + * @returns {*} + */ + getRes: function (url) { + return this.cache[url] || this.cache[_aliases[url]]; + }, + + /** + * Get aliase by url. + * @param url + * @returns {*} + */ + _getAliase: function (url) { + return _aliases[url]; + }, + + /** + * Release the cache of resource by url. + * @param url + */ + release: function (url) { + var cache = this.cache; + var queue = _queue[url]; + if (queue) { + queue.img = null; + delete _queue[url]; + } + delete cache[url]; + delete cache[_aliases[url]]; + delete _aliases[url]; + }, + + /** + * Resource cache of all resources. + */ + releaseAll: function () { + var locCache = this.cache; + for (var key in locCache) + delete locCache[key]; + for (var key in _aliases) + delete _aliases[key]; + } + }; +})(); +//+++++++++++++++++++++++++something about loader end+++++++++++++++++++++++++++++ + +/** + * A string tool to construct a string with format string. + * for example: + * cc.formatStr("a: %d, b: %b", a, b); + * cc.formatStr(a, b, c); + * @returns {String} + */ +cc.formatStr = function () { + var args = arguments; + var l = args.length; + if (l < 1) + return ""; + + var str = args[0]; + var needToFormat = true; + if (typeof str === "object") { + needToFormat = false; + } + for (var i = 1; i < l; ++i) { + var arg = args[i]; + if (needToFormat) { + while (true) { + var result = null; + if (typeof arg === "number") { + result = str.match(/(%d)|(%s)/); + if (result) { + str = str.replace(/(%d)|(%s)/, arg); + break; + } + } + result = str.match(/%s/); + if (result) + str = str.replace(/%s/, arg); + else + str += " " + arg; + break; + } + } else + str += " " + arg; + } + return str; +}; + + +//+++++++++++++++++++++++++Engine initialization function begin+++++++++++++++++++++++++++ +(function () { + +var _tmpCanvas1 = document.createElement("canvas"), + _tmpCanvas2 = document.createElement("canvas"); + +cc.create3DContext = function (canvas, opt_attribs) { + var names = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"]; + var context = null; + for (var ii = 0; ii < names.length; ++ii) { + try { + context = canvas.getContext(names[ii], opt_attribs); + } catch (e) { + } + if (context) { + break; + } + } + return context; +}; + +var _initSys = function () { + /** + * System variables + * @namespace + * @name cc.sys + */ + cc.sys = {}; + var sys = cc.sys; + + /** + * English language code + * @memberof cc.sys + * @name LANGUAGE_ENGLISH + * @constant + * @type {Number} + */ + sys.LANGUAGE_ENGLISH = "en"; + + /** + * Chinese language code + * @memberof cc.sys + * @name LANGUAGE_CHINESE + * @constant + * @type {Number} + */ + sys.LANGUAGE_CHINESE = "zh"; + + /** + * French language code + * @memberof cc.sys + * @name LANGUAGE_FRENCH + * @constant + * @type {Number} + */ + sys.LANGUAGE_FRENCH = "fr"; + + /** + * Italian language code + * @memberof cc.sys + * @name LANGUAGE_ITALIAN + * @constant + * @type {Number} + */ + sys.LANGUAGE_ITALIAN = "it"; + + /** + * German language code + * @memberof cc.sys + * @name LANGUAGE_GERMAN + * @constant + * @type {Number} + */ + sys.LANGUAGE_GERMAN = "de"; + + /** + * Spanish language code + * @memberof cc.sys + * @name LANGUAGE_SPANISH + * @constant + * @type {Number} + */ + sys.LANGUAGE_SPANISH = "es"; + + /** + * Spanish language code + * @memberof cc.sys + * @name LANGUAGE_DUTCH + * @constant + * @type {Number} + */ + sys.LANGUAGE_DUTCH = "du"; + + /** + * Russian language code + * @memberof cc.sys + * @name LANGUAGE_RUSSIAN + * @constant + * @type {Number} + */ + sys.LANGUAGE_RUSSIAN = "ru"; + + /** + * Korean language code + * @memberof cc.sys + * @name LANGUAGE_KOREAN + * @constant + * @type {Number} + */ + sys.LANGUAGE_KOREAN = "ko"; + + /** + * Japanese language code + * @memberof cc.sys + * @name LANGUAGE_JAPANESE + * @constant + * @type {Number} + */ + sys.LANGUAGE_JAPANESE = "ja"; + + /** + * Hungarian language code + * @memberof cc.sys + * @name LANGUAGE_HUNGARIAN + * @constant + * @type {Number} + */ + sys.LANGUAGE_HUNGARIAN = "hu"; + + /** + * Portuguese language code + * @memberof cc.sys + * @name LANGUAGE_PORTUGUESE + * @constant + * @type {Number} + */ + sys.LANGUAGE_PORTUGUESE = "pt"; + + /** + * Arabic language code + * @memberof cc.sys + * @name LANGUAGE_ARABIC + * @constant + * @type {Number} + */ + sys.LANGUAGE_ARABIC = "ar"; + + /** + * Norwegian language code + * @memberof cc.sys + * @name LANGUAGE_NORWEGIAN + * @constant + * @type {Number} + */ + sys.LANGUAGE_NORWEGIAN = "no"; + + /** + * Polish language code + * @memberof cc.sys + * @name LANGUAGE_POLISH + * @constant + * @type {Number} + */ + sys.LANGUAGE_POLISH = "pl"; + + /** + * Unknown language code + * @memberof cc.sys + * @name LANGUAGE_UNKNOWN + * @constant + * @type {Number} + */ + sys.LANGUAGE_UNKNOWN = "unkonwn"; + + /** + * @memberof cc.sys + * @name OS_IOS + * @constant + * @type {string} + */ + sys.OS_IOS = "iOS"; + /** + * @memberof cc.sys + * @name OS_ANDROID + * @constant + * @type {string} + */ + sys.OS_ANDROID = "Android"; + /** + * @memberof cc.sys + * @name OS_WINDOWS + * @constant + * @type {string} + */ + sys.OS_WINDOWS = "Windows"; + /** + * @memberof cc.sys + * @name OS_MARMALADE + * @constant + * @type {string} + */ + sys.OS_MARMALADE = "Marmalade"; + /** + * @memberof cc.sys + * @name OS_LINUX + * @constant + * @type {string} + */ + sys.OS_LINUX = "Linux"; + /** + * @memberof cc.sys + * @name OS_BADA + * @constant + * @type {string} + */ + sys.OS_BADA = "Bada"; + /** + * @memberof cc.sys + * @name OS_BLACKBERRY + * @constant + * @type {string} + */ + sys.OS_BLACKBERRY = "Blackberry"; + /** + * @memberof cc.sys + * @name OS_OSX + * @constant + * @type {string} + */ + sys.OS_OSX = "OS X"; + /** + * @memberof cc.sys + * @name OS_WP8 + * @constant + * @type {string} + */ + sys.OS_WP8 = "WP8"; + /** + * @memberof cc.sys + * @name OS_WINRT + * @constant + * @type {string} + */ + sys.OS_WINRT = "WINRT"; + /** + * @memberof cc.sys + * @name OS_UNKNOWN + * @constant + * @type {string} + */ + sys.OS_UNKNOWN = "Unknown"; + + /** + * @memberof cc.sys + * @name UNKNOWN + * @constant + * @default + * @type {Number} + */ + sys.UNKNOWN = -1; + /** + * @memberof cc.sys + * @name WIN32 + * @constant + * @default + * @type {Number} + */ + sys.WIN32 = 0; + /** + * @memberof cc.sys + * @name LINUX + * @constant + * @default + * @type {Number} + */ + sys.LINUX = 1; + /** + * @memberof cc.sys + * @name MACOS + * @constant + * @default + * @type {Number} + */ + sys.MACOS = 2; + /** + * @memberof cc.sys + * @name ANDROID + * @constant + * @default + * @type {Number} + */ + sys.ANDROID = 3; + /** + * @memberof cc.sys + * @name IOS + * @constant + * @default + * @type {Number} + */ + sys.IPHONE = 4; + /** + * @memberof cc.sys + * @name IOS + * @constant + * @default + * @type {Number} + */ + sys.IPAD = 5; + /** + * @memberof cc.sys + * @name BLACKBERRY + * @constant + * @default + * @type {Number} + */ + sys.BLACKBERRY = 6; + /** + * @memberof cc.sys + * @name NACL + * @constant + * @default + * @type {Number} + */ + sys.NACL = 7; + /** + * @memberof cc.sys + * @name EMSCRIPTEN + * @constant + * @default + * @type {Number} + */ + sys.EMSCRIPTEN = 8; + /** + * @memberof cc.sys + * @name TIZEN + * @constant + * @default + * @type {Number} + */ + sys.TIZEN = 9; + /** + * @memberof cc.sys + * @name WINRT + * @constant + * @default + * @type {Number} + */ + sys.WINRT = 10; + /** + * @memberof cc.sys + * @name WP8 + * @constant + * @default + * @type {Number} + */ + sys.WP8 = 11; + /** + * @memberof cc.sys + * @name MOBILE_BROWSER + * @constant + * @default + * @type {Number} + */ + sys.MOBILE_BROWSER = 100; + /** + * @memberof cc.sys + * @name DESKTOP_BROWSER + * @constant + * @default + * @type {Number} + */ + sys.DESKTOP_BROWSER = 101; + + sys.BROWSER_TYPE_WECHAT = "wechat"; + sys.BROWSER_TYPE_ANDROID = "androidbrowser"; + sys.BROWSER_TYPE_IE = "ie"; + sys.BROWSER_TYPE_QQ_APP = "qq"; // QQ App + sys.BROWSER_TYPE_QQ = "qqbrowser"; + sys.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser"; + sys.BROWSER_TYPE_UC = "ucbrowser"; + sys.BROWSER_TYPE_360 = "360browser"; + sys.BROWSER_TYPE_BAIDU_APP = "baiduboxapp"; + sys.BROWSER_TYPE_BAIDU = "baidubrowser"; + sys.BROWSER_TYPE_MAXTHON = "maxthon"; + sys.BROWSER_TYPE_OPERA = "opera"; + sys.BROWSER_TYPE_OUPENG = "oupeng"; + sys.BROWSER_TYPE_MIUI = "miuibrowser"; + sys.BROWSER_TYPE_FIREFOX = "firefox"; + sys.BROWSER_TYPE_SAFARI = "safari"; + sys.BROWSER_TYPE_CHROME = "chrome"; + sys.BROWSER_TYPE_LIEBAO = "liebao"; + sys.BROWSER_TYPE_QZONE = "qzone"; + sys.BROWSER_TYPE_SOUGOU = "sogou"; + sys.BROWSER_TYPE_UNKNOWN = "unknown"; + + /** + * Is native ? This is set to be true in jsb auto. + * @memberof cc.sys + * @name isNative + * @type {Boolean} + */ + sys.isNative = false; + + var win = window, nav = win.navigator, doc = document, docEle = doc.documentElement; + var ua = nav.userAgent.toLowerCase(); + + /** + * Indicate whether system is mobile system + * @memberof cc.sys + * @name isMobile + * @type {Boolean} + */ + sys.isMobile = /mobile|android|iphone|ipad/.test(ua); + + /** + * Indicate the running platform + * @memberof cc.sys + * @name platform + * @type {Number} + */ + sys.platform = sys.isMobile ? sys.MOBILE_BROWSER : sys.DESKTOP_BROWSER; + + var currLanguage = nav.language; + currLanguage = currLanguage ? currLanguage : nav.browserLanguage; + currLanguage = currLanguage ? currLanguage.split("-")[0] : sys.LANGUAGE_ENGLISH; + + /** + * Indicate the current language of the running system + * @memberof cc.sys + * @name language + * @type {String} + */ + sys.language = currLanguage; + + // Get the os of system + var isAndroid = false, iOS = false, osVersion = '', osMainVersion = 0; + var uaResult = /android (\d+(?:\.\d+)+)/i.exec(ua) || /android (\d+(?:\.\d+)+)/i.exec(nav.platform); + if (uaResult) { + isAndroid = true; + osVersion = uaResult[1] || ''; + osMainVersion = parseInt(osVersion) || 0; + } + uaResult = /(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(ua); + if (uaResult) { + iOS = true; + osVersion = uaResult[2] || ''; + osMainVersion = parseInt(osVersion) || 0; + } + else if (/(iPhone|iPad|iPod)/.exec(nav.platform)) { + iOS = true; + osVersion = ''; + osMainVersion = 0; + } + + var osName = sys.OS_UNKNOWN; + if (nav.appVersion.indexOf("Win") !== -1) osName = sys.OS_WINDOWS; + else if (iOS) osName = sys.OS_IOS; + else if (nav.appVersion.indexOf("Mac") !== -1) osName = sys.OS_OSX; + else if (nav.appVersion.indexOf("X11") !== -1 && nav.appVersion.indexOf("Linux") === -1) osName = sys.OS_UNIX; + else if (isAndroid) osName = sys.OS_ANDROID; + else if (nav.appVersion.indexOf("Linux") !== -1) osName = sys.OS_LINUX; + + /** + * Indicate the running os name + * @memberof cc.sys + * @name os + * @type {String} + */ + sys.os = osName; + /** + * Indicate the running os version string + * @memberof cc.sys + * @name osVersion + * @type {String} + */ + sys.osVersion = osVersion; + /** + * Indicate the running os main version number + * @memberof cc.sys + * @name osMainVersion + * @type {Number} + */ + sys.osMainVersion = osMainVersion; + + /** + * Indicate the running browser type + * @memberof cc.sys + * @name browserType + * @type {String} + */ + sys.browserType = sys.BROWSER_TYPE_UNKNOWN; + /* Determine the browser type */ + (function(){ + var typeReg1 = /micromessenger|mqqbrowser|sogou|qzone|liebao|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|trident|miuibrowser/i; + var typeReg2 = /qqbrowser|qq|chrome|safari|firefox|opr|oupeng|opera/i; + var browserTypes = typeReg1.exec(ua); + if(!browserTypes) browserTypes = typeReg2.exec(ua); + var browserType = browserTypes ? browserTypes[0] : sys.BROWSER_TYPE_UNKNOWN; + if (browserType === 'micromessenger') + browserType = sys.BROWSER_TYPE_WECHAT; + else if (browserType === "safari" && isAndroid) + browserType = sys.BROWSER_TYPE_ANDROID; + else if (browserType === "trident") + browserType = sys.BROWSER_TYPE_IE; + else if (browserType === "360 aphone") + browserType = sys.BROWSER_TYPE_360; + else if (browserType === "mxbrowser") + browserType = sys.BROWSER_TYPE_MAXTHON; + else if (browserType === "opr") + browserType = sys.BROWSER_TYPE_OPERA; + + sys.browserType = browserType; + })(); + + /** + * Indicate the running browser version + * @memberof cc.sys + * @name browserVersion + * @type {String} + */ + sys.browserVersion = ""; + /* Determine the browser version number */ + (function(){ + var versionReg1 = /(mqqbrowser|micromessenger|sogou|qzone|liebao|maxthon|mxbrowser|baidu)(mobile)?(browser)?\/?([\d.]+)/i; + var versionReg2 = /(msie |rv:|firefox|chrome|ucbrowser|qq|oupeng|opera|opr|safari|miui)(mobile)?(browser)?\/?([\d.]+)/i; + var tmp = ua.match(versionReg1); + if(!tmp) tmp = ua.match(versionReg2); + sys.browserVersion = tmp ? tmp[4] : ""; + })(); + + var w = window.innerWidth || document.documentElement.clientWidth; + var h = window.innerHeight || document.documentElement.clientHeight; + var ratio = window.devicePixelRatio || 1; + + /** + * Indicate the real pixel resolution of the whole game window + * @memberof cc.sys + * @name windowPixelResolution + * @type {Size} + */ + sys.windowPixelResolution = { + width: ratio * w, + height: ratio * h + }; + + sys._checkWebGLRenderMode = function () { + if (cc._renderType !== cc.game.RENDER_TYPE_WEBGL) + throw new Error("This feature supports WebGL render mode only."); + }; + + //Whether or not the Canvas BlendModes are supported. + sys._supportCanvasNewBlendModes = (function(){ + var canvas = _tmpCanvas1; + canvas.width = 1; + canvas.height = 1; + var context = canvas.getContext('2d'); + context.fillStyle = '#000'; + context.fillRect(0, 0, 1, 1); + context.globalCompositeOperation = 'multiply'; + + var canvas2 = _tmpCanvas2; + canvas2.width = 1; + canvas2.height = 1; + var context2 = canvas2.getContext('2d'); + context2.fillStyle = '#fff'; + context2.fillRect(0, 0, 1, 1); + context.drawImage(canvas2, 0, 0, 1, 1); + + return context.getImageData(0, 0, 1, 1).data[0] === 0; + })(); + + // Adjust mobile css settings + if (cc.sys.isMobile) { + var fontStyle = document.createElement("style"); + fontStyle.type = "text/css"; + document.body.appendChild(fontStyle); + + fontStyle.textContent = "body,canvas,div{ -moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;" + + "-webkit-tap-highlight-color:rgba(0,0,0,0);}"; + } + + /** + * cc.sys.localStorage is a local storage component. + * @memberof cc.sys + * @name localStorage + * @type {Object} + */ + try { + var localStorage = sys.localStorage = win.localStorage; + localStorage.setItem("storage", ""); + localStorage.removeItem("storage"); + localStorage = null; + } catch (e) { + var warn = function () { + cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"); + }; + sys.localStorage = { + getItem : warn, + setItem : warn, + removeItem : warn, + clear : warn + }; + } + + var _supportCanvas = !!_tmpCanvas1.getContext("2d"); + var _supportWebGL = false; + if (win.WebGLRenderingContext) { + var tmpCanvas = document.createElement("CANVAS"); + try{ + var context = cc.create3DContext(tmpCanvas); + if (context) { + _supportWebGL = true; + } + + if (_supportWebGL && sys.os === sys.OS_IOS && sys.osMainVersion === 9) { + // Not activating WebGL in iOS 9 UIWebView because it may crash when entering background + if (!window.indexedDB) { + _supportWebGL = false; + } + } + + if (_supportWebGL && sys.os === sys.OS_ANDROID) { + var browserVer = parseFloat(sys.browserVersion); + switch (sys.browserType) { + case sys.BROWSER_TYPE_MOBILE_QQ: + case sys.BROWSER_TYPE_BAIDU: + case sys.BROWSER_TYPE_BAIDU_APP: + // QQ & Baidu Brwoser 6.2+ (using blink kernel) + if (browserVer >= 6.2) { + _supportWebGL = true; + } + else { + _supportWebGL = false; + } + break; + case sys.BROWSER_TYPE_CHROME: + // Chrome on android supports WebGL from v.30 + if(browserVer >= 30.0) { + _supportWebGL = true; + } else { + _supportWebGL = false; + } + break; + case sys.BROWSER_TYPE_ANDROID: + // Android 5+ default browser + if (sys.osMainVersion && sys.osMainVersion >= 5) { + _supportWebGL = true; + } + break; + case sys.BROWSER_TYPE_UNKNOWN: + case sys.BROWSER_TYPE_360: + case sys.BROWSER_TYPE_MIUI: + case sys.BROWSER_TYPE_UC: + _supportWebGL = false; + } + } + } + catch (e) {} + tmpCanvas = null; + } + + /** + * The capabilities of the current platform + * @memberof cc.sys + * @name capabilities + * @type {Object} + */ + var capabilities = sys.capabilities = { + "canvas": _supportCanvas, + "opengl": _supportWebGL + }; + if (docEle['ontouchstart'] !== undefined || doc['ontouchstart'] !== undefined || nav.msPointerEnabled) + capabilities["touches"] = true; + if (docEle['onmouseup'] !== undefined) + capabilities["mouse"] = true; + if (docEle['onkeyup'] !== undefined) + capabilities["keyboard"] = true; + if (win.DeviceMotionEvent || win.DeviceOrientationEvent) + capabilities["accelerometer"] = true; + + /** + * Forces the garbage collection, only available in JSB + * @memberof cc.sys + * @name garbageCollect + * @function + */ + sys.garbageCollect = function () { + // N/A in cocos2d-html5 + }; + + /** + * Dumps rooted objects, only available in JSB + * @memberof cc.sys + * @name dumpRoot + * @function + */ + sys.dumpRoot = function () { + // N/A in cocos2d-html5 + }; + + /** + * Restart the JS VM, only available in JSB + * @memberof cc.sys + * @name restartVM + * @function + */ + sys.restartVM = function () { + // N/A in cocos2d-html5 + }; + + /** + * Clean a script in the JS VM, only available in JSB + * @memberof cc.sys + * @name cleanScript + * @param {String} jsfile + * @function + */ + sys.cleanScript = function (jsfile) { + // N/A in cocos2d-html5 + }; + + /** + * Check whether an object is valid, + * In web engine, it will return true if the object exist + * In native engine, it will return true if the JS object and the correspond native object are both valid + * @memberof cc.sys + * @name isObjectValid + * @param {Object} obj + * @return {boolean} Validity of the object + * @function + */ + sys.isObjectValid = function (obj) { + if (obj) return true; + else return false; + }; + + /** + * Dump system informations + * @memberof cc.sys + * @name dump + * @function + */ + sys.dump = function () { + var self = this; + var str = ""; + str += "isMobile : " + self.isMobile + "\r\n"; + str += "language : " + self.language + "\r\n"; + str += "browserType : " + self.browserType + "\r\n"; + str += "browserVersion : " + self.browserVersion + "\r\n"; + str += "capabilities : " + JSON.stringify(self.capabilities) + "\r\n"; + str += "os : " + self.os + "\r\n"; + str += "osVersion : " + self.osVersion + "\r\n"; + str += "platform : " + self.platform + "\r\n"; + str += "Using " + (cc._renderType === cc.game.RENDER_TYPE_WEBGL ? "WEBGL" : "CANVAS") + " renderer." + "\r\n"; + cc.log(str); + }; + + /** + * Open a url in browser + * @memberof cc.sys + * @name openURL + * @param {String} url + */ + sys.openURL = function(url){ + window.open(url); + }; + + /** + * Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + * @memberof cc.sys + * @name now + * @return {Number} + */ + sys.now = function () { + if (Date.now) { + return Date.now(); + } + else { + return +(new Date); + } + }; +}; +_initSys(); + +_tmpCanvas1 = null; +_tmpCanvas2 = null; + +//to make sure the cc.log, cc.warn, cc.error and cc.assert would not throw error before init by debugger mode. +cc.log = cc.warn = cc.error = cc.assert = function () { +}; + +var _config = null, + //cache for js and module that has added into jsList to be loaded. + _jsAddedCache = {}, + _engineInitCalled = false, + _engineLoadedCallback = null; + +cc._engineLoaded = false; + +function _determineRenderType(config) { + var CONFIG_KEY = cc.game.CONFIG_KEY, + userRenderMode = parseInt(config[CONFIG_KEY.renderMode]) || 0; + + // Adjust RenderType + if (isNaN(userRenderMode) || userRenderMode > 2 || userRenderMode < 0) + config[CONFIG_KEY.renderMode] = 0; + + // Determine RenderType + cc._renderType = cc.game.RENDER_TYPE_CANVAS; + cc._supportRender = false; + + if (userRenderMode === 0) { + if (cc.sys.capabilities["opengl"]) { + cc._renderType = cc.game.RENDER_TYPE_WEBGL; + cc._supportRender = true; + } + else if (cc.sys.capabilities["canvas"]) { + cc._renderType = cc.game.RENDER_TYPE_CANVAS; + cc._supportRender = true; + } + } + else if (userRenderMode === 1 && cc.sys.capabilities["canvas"]) { + cc._renderType = cc.game.RENDER_TYPE_CANVAS; + cc._supportRender = true; + } + else if (userRenderMode === 2 && cc.sys.capabilities["opengl"]) { + cc._renderType = cc.game.RENDER_TYPE_WEBGL; + cc._supportRender = true; + } +} + +function _getJsListOfModule(moduleMap, moduleName, dir) { + if (_jsAddedCache[moduleName]) return null; + dir = dir || ""; + var jsList = []; + var tempList = moduleMap[moduleName]; + if (!tempList) throw new Error("can not find module [" + moduleName + "]"); + var ccPath = cc.path; + for (var i = 0, li = tempList.length; i < li; i++) { + var item = tempList[i]; + if (_jsAddedCache[item]) continue; + var extname = ccPath.extname(item); + if (!extname) { + var arr = _getJsListOfModule(moduleMap, item, dir); + if (arr) jsList = jsList.concat(arr); + } else if (extname.toLowerCase() === ".js") jsList.push(ccPath.join(dir, item)); + _jsAddedCache[item] = 1; + } + return jsList; +} + +function _afterEngineLoaded(config) { + if (cc._initDebugSetting) + cc._initDebugSetting(config[cc.game.CONFIG_KEY.debugMode]); + cc._engineLoaded = true; + console.log(cc.ENGINE_VERSION); + if (_engineLoadedCallback) _engineLoadedCallback(); +} + +function _load(config) { + var self = this; + var CONFIG_KEY = cc.game.CONFIG_KEY, engineDir = config[CONFIG_KEY.engineDir], loader = cc.loader; + + if (cc.Class) { + // Single file loaded + _afterEngineLoaded(config); + } else { + // Load cocos modules + var ccModulesPath = cc.path.join(engineDir, "moduleConfig.json"); + loader.loadJson(ccModulesPath, function (err, modulesJson) { + if (err) throw new Error(err); + var modules = config["modules"] || []; + var moduleMap = modulesJson["module"]; + var jsList = []; + if (cc.sys.capabilities["opengl"] && modules.indexOf("base4webgl") < 0) modules.splice(0, 0, "base4webgl"); + else if (modules.indexOf("core") < 0) modules.splice(0, 0, "core"); + for (var i = 0, li = modules.length; i < li; i++) { + var arr = _getJsListOfModule(moduleMap, modules[i], engineDir); + if (arr) jsList = jsList.concat(arr); + } + cc.loader.loadJsWithImg(jsList, function (err) { + if (err) throw err; + _afterEngineLoaded(config); + }); + }); + } +} + +function _windowLoaded() { + this.removeEventListener('load', _windowLoaded, false); + _load(cc.game.config); +} + +cc.initEngine = function (config, cb) { + if (_engineInitCalled) { + var previousCallback = _engineLoadedCallback; + _engineLoadedCallback = function () { + previousCallback && previousCallback(); + cb && cb(); + } + return; + } + + _engineLoadedCallback = cb; + + // Config uninitialized and given, initialize with it + if (!cc.game.config && config) { + cc.game.config = config; + } + // No config given and no config set before, load it + else if (!cc.game.config) { + cc.game._loadConfig(); + } + config = cc.game.config; + + _determineRenderType(config); + + document.body ? _load(config) : cc._addEventListener(window, 'load', _windowLoaded, false); + _engineInitCalled = true; +}; + +})(); +//+++++++++++++++++++++++++Engine initialization function end+++++++++++++++++++++++++++++ + +//+++++++++++++++++++++++++something about CCGame begin+++++++++++++++++++++++++++ +/** + * An object to boot the game. + * @class + * @name cc.game + * + */ +cc.game = /** @lends cc.game# */{ + /** + * Debug mode: No debugging. {@static} + * @const {Number} + * @static + */ + DEBUG_MODE_NONE: 0, + /** + * Debug mode: Info, warning, error to console. + * @const {Number} + * @static + */ + DEBUG_MODE_INFO: 1, + /** + * Debug mode: Warning, error to console. + * @const {Number} + * @static + */ + DEBUG_MODE_WARN: 2, + /** + * Debug mode: Error to console. + * @const {Number} + * @static + */ + DEBUG_MODE_ERROR: 3, + /** + * Debug mode: Info, warning, error to web page. + * @const {Number} + * @static + */ + DEBUG_MODE_INFO_FOR_WEB_PAGE: 4, + /** + * Debug mode: Warning, error to web page. + * @const {Number} + * @static + */ + DEBUG_MODE_WARN_FOR_WEB_PAGE: 5, + /** + * Debug mode: Error to web page. + * @const {Number} + * @static + */ + DEBUG_MODE_ERROR_FOR_WEB_PAGE: 6, + + /** + * Event that is fired when the game is hidden. + * @constant {String} + */ + EVENT_HIDE: "game_on_hide", + /** + * Event that is fired when the game is shown. + * @constant {String} + */ + EVENT_SHOW: "game_on_show", + /** + * Event that is fired when the game is resized. + * @constant {String} + */ + EVENT_RESIZE: "game_on_resize", + /** + * Event that is fired when the renderer is done being initialized. + * @constant {String} + */ + EVENT_RENDERER_INITED: "renderer_inited", + + /** @constant {Number} */ + RENDER_TYPE_CANVAS: 0, + /** @constant {Number} */ + RENDER_TYPE_WEBGL: 1, + /** @constant {Number} */ + RENDER_TYPE_OPENGL: 2, + + _eventHide: null, + _eventShow: null, + + /** + * Keys found in project.json. + * + * @constant + * @type {Object} + * + * @prop {String} engineDir - In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir". + * @prop {String} modules - Defines which modules you will need in your game, it's useful only on web + * @prop {String} debugMode - Debug mode, see DEBUG_MODE_XXX constant definitions. + * @prop {String} exposeClassName - Expose class name to chrome debug tools + * @prop {String} showFPS - Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide. + * @prop {String} frameRate - Sets the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. + * @prop {String} id - Sets the id of your canvas element on the web page, it's useful only on web. + * @prop {String} renderMode - Sets the renderer type, only useful on web, 0: Automatic, 1: Canvas, 2: WebGL + * @prop {String} jsList - Sets the list of js files in your game. + */ + CONFIG_KEY: { + width: "width", + height: "height", + engineDir: "engineDir", + modules: "modules", + debugMode: "debugMode", + exposeClassName: "exposeClassName", + showFPS: "showFPS", + frameRate: "frameRate", + id: "id", + renderMode: "renderMode", + jsList: "jsList" + }, + + // states + _paused: true,//whether the game is paused + _configLoaded: false,//whether config loaded + _prepareCalled: false,//whether the prepare function has been called + _prepared: false,//whether the engine has prepared + _rendererInitialized: false, + + _renderContext: null, + + _intervalId: null,//interval target of main + + _lastTime: null, + _frameTime: null, + + /** + * The outer frame of the game canvas, parent of cc.container + * @type {Object} + */ + frame: null, + /** + * The container of game canvas, equals to cc.container + * @type {Object} + */ + container: null, + /** + * The canvas of the game, equals to cc._canvas + * @type {Object} + */ + canvas: null, + + /** + * Config of game + * @type {Object} + */ + config: null, + + /** + * Callback when the scripts of engine have been load. + * @type {Function|null} + */ + onStart: null, + + /** + * Callback when game exits. + * @type {Function|null} + */ + onStop: null, + +//@Public Methods + +// @Game play control + /** + * Set frameRate of game. + * @param frameRate + */ + setFrameRate: function (frameRate) { + var self = this, config = self.config, CONFIG_KEY = self.CONFIG_KEY; + config[CONFIG_KEY.frameRate] = frameRate; + if (self._intervalId) + window.cancelAnimationFrame(self._intervalId); + self._intervalId = 0; + self._paused = true; + self._setAnimFrame(); + self._runMainLoop(); + }, + + /** + * Run the game frame by frame. + */ + step: function () { + cc.director.mainLoop(); + }, + + /** + * Pause the game. + */ + pause: function () { + if (this._paused) return; + this._paused = true; + // Pause audio engine + if (cc.audioEngine) { + cc.audioEngine._pausePlaying(); + } + // Pause main loop + if (this._intervalId) + window.cancelAnimationFrame(this._intervalId); + this._intervalId = 0; + }, + + /** + * Resume the game from pause. + */ + resume: function () { + if (!this._paused) return; + this._paused = false; + // Resume audio engine + if (cc.audioEngine) { + cc.audioEngine._resumePlaying(); + } + // Resume main loop + this._runMainLoop(); + }, + + /** + * Check whether the game is paused. + */ + isPaused: function () { + return this._paused; + }, + + /** + * Restart game. + */ + restart: function () { + cc.director.popToSceneStackLevel(0); + // Clean up audio + cc.audioEngine && cc.audioEngine.end(); + + cc.game.onStart(); + }, + + /** + * End game, it will close the game window + */ + end: function () { + close(); + }, + +// @Game loading + /** + * Prepare game. + * @param cb + */ + prepare: function (cb) { + var self = this, + config = self.config, + CONFIG_KEY = self.CONFIG_KEY; + + // Config loaded + if (!this._configLoaded) { + this._loadConfig(function () { + self.prepare(cb); + }); + return; + } + + // Already prepared + if (this._prepared) { + if (cb) cb(); + return; + } + // Prepare called, but not done yet + if (this._prepareCalled) { + return; + } + // Prepare never called and engine ready + if (cc._engineLoaded) { + this._prepareCalled = true; + + this._initRenderer(config[CONFIG_KEY.width], config[CONFIG_KEY.height]); + + /** + * cc.view is the shared view object. + * @type {cc.EGLView} + * @name cc.view + * @memberof cc + */ + cc.view = cc.EGLView._getInstance(); + + /** + * @type {cc.Director} + * @name cc.director + * @memberof cc + */ + cc.director = cc.Director._getInstance(); + if (cc.director.setOpenGLView) + cc.director.setOpenGLView(cc.view); + /** + * cc.winSize is the alias object for the size of the current game window. + * @type {cc.Size} + * @name cc.winSize + * @memberof cc + */ + cc.winSize = cc.director.getWinSize(); + + this._initEvents(); + + this._setAnimFrame(); + this._runMainLoop(); + + // Load game scripts + var jsList = config[CONFIG_KEY.jsList]; + if (jsList) { + cc.loader.loadJsWithImg(jsList, function (err) { + if (err) throw new Error(err); + self._prepared = true; + if (cb) cb(); + }); + } + else { + if (cb) cb(); + } + + return; + } + + // Engine not loaded yet + cc.initEngine(this.config, function () { + self.prepare(cb); + }); + }, + + /** + * Run game with configuration object and onStart function. + * @param {Object|Function} [config] Pass configuration object or onStart function + * @param {onStart} [onStart] onStart function to be executed after game initialized + */ + run: function (config, onStart) { + if (typeof config === 'function') { + cc.game.onStart = config; + } + else { + if (config) { + if (typeof config === 'string') { + if (!cc.game.config) this._loadConfig(); + cc.game.config[cc.game.CONFIG_KEY.id] = config; + } else { + cc.game.config = config; + } + } + if (typeof onStart === 'function') { + cc.game.onStart = onStart; + } + } + + this.prepare(cc.game.onStart && cc.game.onStart.bind(cc.game)); + }, + +//@Private Methods + +// @Time ticker section + _setAnimFrame: function () { + this._lastTime = new Date(); + var frameRate = cc.game.config[cc.game.CONFIG_KEY.frameRate]; + this._frameTime = 1000 / frameRate; + if (frameRate !== 60 && frameRate !== 30) { + window.requestAnimFrame = this._stTime; + window.cancelAnimationFrame = this._ctTime; + } + else { + window.requestAnimFrame = window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + this._stTime; + window.cancelAnimationFrame = window.cancelAnimationFrame || + window.cancelRequestAnimationFrame || + window.msCancelRequestAnimationFrame || + window.mozCancelRequestAnimationFrame || + window.oCancelRequestAnimationFrame || + window.webkitCancelRequestAnimationFrame || + window.msCancelAnimationFrame || + window.mozCancelAnimationFrame || + window.webkitCancelAnimationFrame || + window.oCancelAnimationFrame || + this._ctTime; + } + }, + _stTime: function (callback) { + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, cc.game._frameTime - (currTime - cc.game._lastTime)); + var id = window.setTimeout(function() { callback(); }, + timeToCall); + cc.game._lastTime = currTime + timeToCall; + return id; + }, + _ctTime: function (id) { + window.clearTimeout(id); + }, + //Run game. + _runMainLoop: function () { + var self = this, callback, config = self.config, CONFIG_KEY = self.CONFIG_KEY, + director = cc.director, + skip = true, frameRate = config[CONFIG_KEY.frameRate]; + + director.setDisplayStats(config[CONFIG_KEY.showFPS]); + + callback = function () { + if (!self._paused) { + if (frameRate === 30) { + if (skip = !skip) { + self._intervalId = window.requestAnimFrame(callback); + return; + } + } + + director.mainLoop(); + self._intervalId = window.requestAnimFrame(callback); + } + }; + + self._intervalId = window.requestAnimFrame(callback); + self._paused = false; + }, + +// @Game loading section + _loadConfig: function (cb) { + // Load config + var config = this.config || document["ccConfig"]; + // Already loaded or Load from document.ccConfig + if (config) { + this._initConfig(config); + cb && cb(); + } + // Load from project.json + else { + var cocos_script = document.getElementsByTagName('script'); + for (var i = 0; i < cocos_script.length; i++) { + var _t = cocos_script[i].getAttribute('cocos'); + if (_t === '' || _t) { + break; + } + } + var self = this; + var loaded = function (err, txt) { + var data = JSON.parse(txt); + self._initConfig(data); + cb && cb(); + }; + var _src, txt, _resPath; + if (i < cocos_script.length) { + _src = cocos_script[i].src; + if (_src) { + _resPath = /(.*)\//.exec(_src)[0]; + cc.loader.resPath = _resPath; + _src = cc.path.join(_resPath, 'project.json'); + } + cc.loader.loadTxt(_src, loaded); + } + if (!txt) { + cc.loader.loadTxt("project.json", loaded); + } + } + }, + + _initConfig: function (config) { + var CONFIG_KEY = this.CONFIG_KEY, + modules = config[CONFIG_KEY.modules]; + + // Configs adjustment + config[CONFIG_KEY.showFPS] = typeof config[CONFIG_KEY.showFPS] === 'undefined' ? true : config[CONFIG_KEY.showFPS]; + config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || "frameworks/cocos2d-html5"; + if (config[CONFIG_KEY.debugMode] == null) + config[CONFIG_KEY.debugMode] = 0; + config[CONFIG_KEY.exposeClassName] = !!config[CONFIG_KEY.exposeClassName]; + config[CONFIG_KEY.frameRate] = config[CONFIG_KEY.frameRate] || 60; + if (config[CONFIG_KEY.renderMode] == null) + config[CONFIG_KEY.renderMode] = 0; + if (config[CONFIG_KEY.registerSystemEvent] == null) + config[CONFIG_KEY.registerSystemEvent] = true; + + // Modules adjustment + if (modules && modules.indexOf("core") < 0) modules.splice(0, 0, "core"); + modules && (config[CONFIG_KEY.modules] = modules); + this.config = config; + this._configLoaded = true; + }, + + _initRenderer: function (width, height) { + // Avoid setup to be called twice. + if (this._rendererInitialized) return; + + if (!cc._supportRender) { + throw new Error("The renderer doesn't support the renderMode " + this.config[this.CONFIG_KEY.renderMode]); + } + + var el = this.config[cc.game.CONFIG_KEY.id], + win = window, + element = cc.$(el) || cc.$('#' + el), + localCanvas, localContainer, localConStyle; + + if (element.tagName === "CANVAS") { + width = width || element.width; + height = height || element.height; + + //it is already a canvas, we wrap it around with a div + this.canvas = cc._canvas = localCanvas = element; + this.container = cc.container = localContainer = document.createElement("DIV"); + if (localCanvas.parentNode) + localCanvas.parentNode.insertBefore(localContainer, localCanvas); + } else { + //we must make a new canvas and place into this element + if (element.tagName !== "DIV") { + cc.log("Warning: target element is not a DIV or CANVAS"); + } + width = width || element.clientWidth; + height = height || element.clientHeight; + this.canvas = cc._canvas = localCanvas = cc.$(document.createElement("CANVAS")); + this.container = cc.container = localContainer = document.createElement("DIV"); + element.appendChild(localContainer); + } + localContainer.setAttribute('id', 'Cocos2dGameContainer'); + localContainer.appendChild(localCanvas); + this.frame = (localContainer.parentNode === document.body) ? document.documentElement : localContainer.parentNode; + + localCanvas.addClass("gameCanvas"); + localCanvas.setAttribute("width", width || 480); + localCanvas.setAttribute("height", height || 320); + localCanvas.setAttribute("tabindex", 99); + + if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) { + this._renderContext = cc._renderContext = cc.webglContext + = cc.create3DContext(localCanvas, { + 'stencil': true, + 'alpha': false + }); + } + // WebGL context created successfully + if (this._renderContext) { + cc.renderer = cc.rendererWebGL; + win.gl = this._renderContext; // global variable declared in CCMacro.js + cc.renderer.init(); + cc._drawingUtil = new cc.DrawingPrimitiveWebGL(this._renderContext); + cc.textureCache._initializingRenderer(); + cc.glExt = {}; + cc.glExt.instanced_arrays = win.gl.getExtension("ANGLE_instanced_arrays"); + cc.glExt.element_uint = win.gl.getExtension("OES_element_index_uint"); + } else { + cc._renderType = cc.game.RENDER_TYPE_CANVAS; + cc.renderer = cc.rendererCanvas; + this._renderContext = cc._renderContext = new cc.CanvasContextWrapper(localCanvas.getContext("2d")); + cc._drawingUtil = cc.DrawingPrimitiveCanvas ? new cc.DrawingPrimitiveCanvas(this._renderContext) : null; + } + + cc._gameDiv = localContainer; + cc.game.canvas.oncontextmenu = function () { + if (!cc._isContextMenuEnable) return false; + }; + + this.dispatchEvent(this.EVENT_RENDERER_INITED, true); + + this._rendererInitialized = true; + }, + + _initEvents: function () { + var win = window, hidden; + + this._eventHide = this._eventHide || new cc.EventCustom(this.EVENT_HIDE); + this._eventHide.setUserData(this); + this._eventShow = this._eventShow || new cc.EventCustom(this.EVENT_SHOW); + this._eventShow.setUserData(this); + + // register system events + if (this.config[this.CONFIG_KEY.registerSystemEvent]) + cc.inputManager.registerSystemEvent(this.canvas); + + if (!cc.isUndefined(document.hidden)) { + hidden = "hidden"; + } else if (!cc.isUndefined(document.mozHidden)) { + hidden = "mozHidden"; + } else if (!cc.isUndefined(document.msHidden)) { + hidden = "msHidden"; + } else if (!cc.isUndefined(document.webkitHidden)) { + hidden = "webkitHidden"; + } + + var changeList = [ + "visibilitychange", + "mozvisibilitychange", + "msvisibilitychange", + "webkitvisibilitychange", + "qbrowserVisibilityChange" + ]; + var onHidden = function () { + if (cc.eventManager && cc.game._eventHide) + cc.eventManager.dispatchEvent(cc.game._eventHide); + }; + var onShow = function () { + if (cc.eventManager && cc.game._eventShow) + cc.eventManager.dispatchEvent(cc.game._eventShow); + }; + + if (hidden) { + for (var i=0; i -1) { + win.onfocus = function(){ onShow() }; + } + + if ("onpageshow" in window && "onpagehide" in window) { + win.addEventListener("pagehide", onHidden, false); + win.addEventListener("pageshow", onShow, false); + } + + cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function () { + cc.game.pause(); + }); + cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function () { + cc.game.resume(); + }); + } +}; +//+++++++++++++++++++++++++something about CCGame end+++++++++++++++++++++++++++++ + +Function.prototype.bind = Function.prototype.bind || function (oThis) { + if (!cc.isFunction(this)) { + // closest thing possible to the ECMAScript 5 + // internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; +}; diff --git a/CCDebugger.js b/CCDebugger.js new file mode 100644 index 0000000000..7acfc1cb0d --- /dev/null +++ b/CCDebugger.js @@ -0,0 +1,333 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc._LogInfos = { + ActionManager_addAction: "cc.ActionManager.addAction(): action must be non-null", + ActionManager_removeAction: "cocos2d: removeAction: Target not found", + ActionManager_removeActionByTag: "cc.ActionManager.removeActionByTag(): an invalid tag", + ActionManager_removeActionByTag_2: "cc.ActionManager.removeActionByTag(): target must be non-null", + ActionManager_getActionByTag: "cc.ActionManager.getActionByTag(): an invalid tag", + ActionManager_getActionByTag_2: "cocos2d : getActionByTag(tag = %s): Action not found", + + configuration_dumpInfo: "cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)", + configuration_loadConfigFile: "Expected 'data' dict, but not found. Config file: %s", + configuration_loadConfigFile_2: "Please load the resource first : %s", + + Director_resume: "cocos2d: Director: Error in gettimeofday", + Director_setProjection: "cocos2d: Director: unrecognized projection", + Director_popToSceneStackLevel: "cocos2d: Director: unrecognized projection", + Director_popToSceneStackLevel_2: "cocos2d: Director: Error in gettimeofday", + Director_popScene: "running scene should not null", + Director_pushScene: "the scene should not null", + + arrayVerifyType: "element type is wrong!", + + Scheduler_scheduleCallbackForTarget: "CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s", + Scheduler_scheduleCallbackForTarget_2: "cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null.", + Scheduler_scheduleCallbackForTarget_3: "cc.scheduler.scheduleCallbackForTarget(): target should be non-null.", + Scheduler_pauseTarget: "cc.Scheduler.pauseTarget():target should be non-null", + Scheduler_resumeTarget: "cc.Scheduler.resumeTarget():target should be non-null", + Scheduler_isTargetPaused: "cc.Scheduler.isTargetPaused():target should be non-null", + + Node_getZOrder: "getZOrder is deprecated. Please use getLocalZOrder instead.", + Node_setZOrder: "setZOrder is deprecated. Please use setLocalZOrder instead.", + Node_getRotation: "RotationX != RotationY. Don't know which one to return", + Node_getScale: "ScaleX != ScaleY. Don't know which one to return", + Node_addChild: "An Node can't be added as a child of itself.", + Node_addChild_2: "child already added. It can't be added again", + Node_addChild_3: "child must be non-null", + Node_removeFromParentAndCleanup: "removeFromParentAndCleanup is deprecated. Use removeFromParent instead", + Node_boundingBox: "boundingBox is deprecated. Use getBoundingBox instead", + Node_removeChildByTag: "argument tag is an invalid tag", + Node_removeChildByTag_2: "cocos2d: removeChildByTag(tag = %s): child not found!", + Node_removeAllChildrenWithCleanup: "removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead", + Node_stopActionByTag: "cc.Node.stopActionBy(): argument tag an invalid tag", + Node_getActionByTag: "cc.Node.getActionByTag(): argument tag is an invalid tag", + Node_resumeSchedulerAndActions: "resumeSchedulerAndActions is deprecated, please use resume instead.", + Node_pauseSchedulerAndActions: "pauseSchedulerAndActions is deprecated, please use pause instead.", + Node__arrayMakeObjectsPerformSelector: "Unknown callback function", + Node_reorderChild: "cc.Node.reorderChild(): child must be non-null", + Node_reorderChild_2: "cc.Node.reorderChild(): this child is not in children list", + Node_runAction: "cc.Node.runAction(): action must be non-null", + Node_schedule: "callback function must be non-null", + Node_schedule_2: "interval must be positive", + Node_initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.", + + AtlasNode_updateAtlasValues: "cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses", + AtlasNode_initWithTileFile: "", + AtlasNode__initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.", + + _EventListenerKeyboard_checkAvailable: "cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!", + _EventListenerTouchOneByOne_checkAvailable: "cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!", + _EventListenerTouchAllAtOnce_checkAvailable: "cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!", + _EventListenerAcceleration_checkAvailable: "cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non-nil", + + EventListener_create: "Invalid parameter.", + + __getListenerID: "Don't call this method if the event is for touch.", + + eventManager__forceAddEventListener: "Invalid scene graph priority!", + eventManager_addListener: "0 priority is forbidden for fixed priority since it's used for scene graph based priority.", + eventManager_removeListeners: "Invalid listener type!", + eventManager_setPriority: "Can't set fixed priority with scene graph based listener.", + eventManager_addListener_2: "Invalid parameters.", + eventManager_addListener_3: "listener must be a cc.EventListener object when adding a fixed priority listener", + eventManager_addListener_4: "The listener has been registered, please don't register it again.", + + LayerMultiplex_initWithLayers: "parameters should not be ending with null in Javascript", + LayerMultiplex_switchTo: "Invalid index in MultiplexLayer switchTo message", + LayerMultiplex_switchToAndReleaseMe: "Invalid index in MultiplexLayer switchTo message", + LayerMultiplex_addLayer: "cc.Layer.addLayer(): layer should be non-null", + + EGLView_setDesignResolutionSize: "Resolution not valid", + EGLView_setDesignResolutionSize_2: "should set resolutionPolicy", + + inputManager_handleTouchesBegin: "The touches is more than MAX_TOUCHES, nUnusedIndex = %s", + + swap: "cc.swap is being modified from original macro, please check usage", + checkGLErrorDebug: "WebGL error %s", + + animationCache__addAnimationsWithDictionary: "cocos2d: cc.AnimationCache: No animations were found in provided dictionary.", + animationCache__addAnimationsWithDictionary_2: "cc.AnimationCache. Invalid animation format", + animationCache_addAnimations: "cc.AnimationCache.addAnimations(): File could not be found", + animationCache__parseVersion1: "cocos2d: cc.AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", + animationCache__parseVersion1_2: "cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.", + animationCache__parseVersion1_3: "cocos2d: cc.AnimationCache: None of the frames for animation '%s' were found in the cc.SpriteFrameCache. Animation is not being added to the Animation Cache.", + animationCache__parseVersion1_4: "cocos2d: cc.AnimationCache: An animation in your dictionary refers to a frame which is not in the cc.SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", + animationCache__parseVersion2: "cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", + animationCache__parseVersion2_2: "cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.", + animationCache_addAnimations_2: "cc.AnimationCache.addAnimations(): Invalid texture file name", + + Sprite_ignoreAnchorPointForPosition: "cc.Sprite.ignoreAnchorPointForPosition(): it is invalid in cc.Sprite when using SpriteBatchNode", + Sprite_setDisplayFrameWithAnimationName: "cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found", + Sprite_setDisplayFrameWithAnimationName_2: "cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index", + Sprite_setDisplayFrame: "setDisplayFrame is deprecated, please use setSpriteFrame instead.", + Sprite__updateBlendFunc: "cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode", + Sprite_initWithSpriteFrame: "cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null", + Sprite_initWithSpriteFrameName: "cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null", + Sprite_initWithSpriteFrameName1: " is null, please check.", + Sprite_initWithFile: "cc.Sprite.initWithFile(): filename should be non-null", + Sprite_setDisplayFrameWithAnimationName_3: "cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null", + Sprite_addChild: "cc.Sprite.addChild(): cc.Sprite only supports cc.Sprites as children when using cc.SpriteBatchNode", + Sprite_addChild_2: "cc.Sprite.addChild(): cc.Sprite only supports a sprite using same texture as children when using cc.SpriteBatchNode", + Sprite_addChild_3: "cc.Sprite.addChild(): child should be non-null", + Sprite_setTexture: "cc.Sprite.texture setter: Batched sprites should use the same texture as the batchnode", + Sprite_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", + Sprite_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", + Sprite_addChild_4: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children", + Sprite_addChild_5: "cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture", + Sprite_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ", + Sprite_setSpriteFrame: "Invalid spriteFrameName", + Sprite_setTexture_2: "Invalid argument: cc.Sprite.texture setter expects a CCTexture2D.", + Sprite_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null", + Sprite_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null", + + SpriteBatchNode_addSpriteWithoutQuad: "cc.SpriteBatchNode.addQuadFromSprite(): SpriteBatchNode only supports cc.Sprites as children", + SpriteBatchNode_increaseAtlasCapacity: "cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from %s to %s.", + SpriteBatchNode_increaseAtlasCapacity_2: "cocos2d: WARNING: Not enough memory to resize the atlas", + SpriteBatchNode_reorderChild: "cc.SpriteBatchNode.addChild(): Child doesn't belong to Sprite", + SpriteBatchNode_removeChild: "cc.SpriteBatchNode.addChild(): sprite batch node should contain the child", + SpriteBatchNode_addSpriteWithoutQuad_2: "cc.SpriteBatchNode.addQuadFromSprite(): child should be non-null", + SpriteBatchNode_reorderChild_2: "cc.SpriteBatchNode.addChild(): child should be non-null", + + spriteFrameCache__getFrameConfig: "cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist", + spriteFrameCache_addSpriteFrames: "cocos2d: WARNING: an alias with name %s already exists", + spriteFrameCache__checkConflict: "cocos2d: WARNING: Sprite frame: %s has already been added by another source, please fix name conflit", + spriteFrameCache_getSpriteFrame: "cocos2d: cc.SpriteFrameCahce: Frame %s not found", + spriteFrameCache__getFrameConfig_2: "Please load the resource first : %s", + spriteFrameCache_addSpriteFrames_2: "cc.SpriteFrameCache.addSpriteFrames(): plist should be non-null", + spriteFrameCache_addSpriteFrames_3: "Argument must be non-nil", + + CCSpriteBatchNode_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", + CCSpriteBatchNode_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", + CCSpriteBatchNode_addChild: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children", + CCSpriteBatchNode_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ", + CCSpriteBatchNode_addChild_2: "cc.Sprite.addChild(): child should be non-null", + CCSpriteBatchNode_setSpriteFrame: "Invalid spriteFrameName", + CCSpriteBatchNode_setTexture: "Invalid argument: cc.Sprite texture setter expects a CCTexture2D.", + CCSpriteBatchNode_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null", + CCSpriteBatchNode_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null", + CCSpriteBatchNode_addChild_3: "cc.SpriteBatchNode.addChild(): child should be non-null", + + TextureAtlas_initWithFile: "cocos2d: Could not open file: %s", + TextureAtlas_insertQuad: "cc.TextureAtlas.insertQuad(): invalid totalQuads", + TextureAtlas_initWithTexture: "cc.TextureAtlas.initWithTexture():texture should be non-null", + TextureAtlas_updateQuad: "cc.TextureAtlas.updateQuad(): quad should be non-null", + TextureAtlas_updateQuad_2: "cc.TextureAtlas.updateQuad(): Invalid index", + TextureAtlas_insertQuad_2: "cc.TextureAtlas.insertQuad(): Invalid index", + TextureAtlas_insertQuads: "cc.TextureAtlas.insertQuad(): Invalid index + amount", + TextureAtlas_insertQuadFromIndex: "cc.TextureAtlas.insertQuadFromIndex(): Invalid newIndex", + TextureAtlas_insertQuadFromIndex_2: "cc.TextureAtlas.insertQuadFromIndex(): Invalid fromIndex", + TextureAtlas_removeQuadAtIndex: "cc.TextureAtlas.removeQuadAtIndex(): Invalid index", + TextureAtlas_removeQuadsAtIndex: "cc.TextureAtlas.removeQuadsAtIndex(): index + amount out of bounds", + TextureAtlas_moveQuadsFromIndex: "cc.TextureAtlas.moveQuadsFromIndex(): move is out of bounds", + TextureAtlas_moveQuadsFromIndex_2: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid newIndex", + TextureAtlas_moveQuadsFromIndex_3: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid oldIndex", + + textureCache_addPVRTCImage: "TextureCache:addPVRTCImage does not support on HTML5", + textureCache_addETCImage: "TextureCache:addPVRTCImage does not support on HTML5", + textureCache_textureForKey: "textureForKey is deprecated. Please use getTextureForKey instead.", + textureCache_addPVRImage: "addPVRImage does not support on HTML5", + textureCache_addUIImage: "cocos2d: Couldn't add UIImage in TextureCache", + textureCache_dumpCachedTextureInfo: "cocos2d: '%s' id=%s %s x %s", + textureCache_dumpCachedTextureInfo_2: "cocos2d: '%s' id= HTMLCanvasElement %s x %s", + textureCache_dumpCachedTextureInfo_3: "cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB)", + textureCache_addUIImage_2: "cc.Texture.addUIImage(): image should be non-null", + + Texture2D_initWithETCFile: "initWithETCFile does not support on HTML5", + Texture2D_initWithPVRFile: "initWithPVRFile does not support on HTML5", + Texture2D_initWithPVRTCData: "initWithPVRTCData does not support on HTML5", + Texture2D_addImage: "cc.Texture.addImage(): path should be non-null", + Texture2D_initWithImage: "cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil", + Texture2D_initWithImage_2: "cocos2d: WARNING: Image (%s x %s) is bigger than the supported %s x %s", + Texture2D_initWithString: "initWithString isn't supported on cocos2d-html5", + Texture2D_initWithETCFile_2: "initWithETCFile does not support on HTML5", + Texture2D_initWithPVRFile_2: "initWithPVRFile does not support on HTML5", + Texture2D_initWithPVRTCData_2: "initWithPVRTCData does not support on HTML5", + Texture2D_bitsPerPixelForFormat: "bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format", + Texture2D__initPremultipliedATextureWithImage: "cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha", + Texture2D_addImage_2: "cc.Texture.addImage(): path should be non-null", + Texture2D_initWithData: "NSInternalInconsistencyException", + + MissingFile: "Missing file: %s", + radiansToDegress: "cc.radiansToDegress() should be called cc.radiansToDegrees()", + RectWidth: "Rect width exceeds maximum margin: %s", + RectHeight: "Rect height exceeds maximum margin: %s", + + EventManager__updateListeners: "If program goes here, there should be event in dispatch.", + EventManager__updateListeners_2: "_inDispatch should be 1 here." +}; + +//+++++++++++++++++++++++++something about log start++++++++++++++++++++++++++++ +cc._logToWebPage = function (msg) { + if (!cc._canvas) + return; + + var logList = cc._logList; + var doc = document; + if (!logList) { + var logDiv = doc.createElement("Div"); + var logDivStyle = logDiv.style; + + logDiv.setAttribute("id", "logInfoDiv"); + cc._canvas.parentNode.appendChild(logDiv); + logDiv.setAttribute("width", "200"); + logDiv.setAttribute("height", cc._canvas.height); + logDivStyle.zIndex = "99999"; + logDivStyle.position = "absolute"; + logDivStyle.top = "0"; + logDivStyle.left = "0"; + + logList = cc._logList = doc.createElement("textarea"); + var logListStyle = logList.style; + + logList.setAttribute("rows", "20"); + logList.setAttribute("cols", "30"); + logList.setAttribute("disabled", true); + logDiv.appendChild(logList); + logListStyle.backgroundColor = "transparent"; + logListStyle.borderBottom = "1px solid #cccccc"; + logListStyle.borderRightWidth = "0px"; + logListStyle.borderLeftWidth = "0px"; + logListStyle.borderTopWidth = "0px"; + logListStyle.borderTopStyle = "none"; + logListStyle.borderRightStyle = "none"; + logListStyle.borderLeftStyle = "none"; + logListStyle.padding = "0px"; + logListStyle.margin = 0; + + } + logList.value = logList.value + msg + "\r\n"; + logList.scrollTop = logList.scrollHeight; +}; + +//to make sure the cc.log, cc.warn, cc.error and cc.assert would not throw error before init by debugger mode. +cc._formatString = function (arg) { + if (cc.isObject(arg)) { + try { + return JSON.stringify(arg); + } catch (err) { + return ""; + } + } else + return arg; +}; +/** + * Init Debug setting. + * @function + * @param {Number} mode + */ +cc._initDebugSetting = function (mode) { + var ccGame = cc.game; + if(mode === ccGame.DEBUG_MODE_NONE) + return; + + var locLog; + if(mode > ccGame.DEBUG_MODE_ERROR){ + //log to web page + locLog = cc._logToWebPage.bind(cc); + cc.error = function(){ + locLog("ERROR : " + cc.formatStr.apply(cc, arguments)); + }; + cc.assert = function(cond, msg) { + if (!cond && msg) { + for (var i = 2; i < arguments.length; i++) + msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); + locLog("Assert: " + msg); + } + }; + if(mode !== ccGame.DEBUG_MODE_ERROR_FOR_WEB_PAGE){ + cc.warn = function(){ + locLog("WARN : " + cc.formatStr.apply(cc, arguments)); + }; + } + if(mode === ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE){ + cc.log = function(){ + locLog(cc.formatStr.apply(cc, arguments)); + }; + } + } else if(console && console.log.apply){//console is null when user doesn't open dev tool on IE9 + //log to console + + cc.error = Function.prototype.bind.call(console.error, console); + //If console.assert is not support user throw Error msg on wrong condition + if (console.assert) { + cc.assert = Function.prototype.bind.call(console.assert, console); + } else { + cc.assert = function (cond, msg) { + if (!cond && msg) { + for (var i = 2; i < arguments.length; i++) + msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); + throw new Error(msg); + } + }; + } + if (mode !== ccGame.DEBUG_MODE_ERROR) + cc.warn = Function.prototype.bind.call(console.warn, console); + if (mode === ccGame.DEBUG_MODE_INFO) + cc.log = Function.prototype.bind.call(console.log, console); + } +}; +//+++++++++++++++++++++++++something about log end+++++++++++++++++++++++++++++ diff --git a/CHANGELOG.txt b/CHANGELOG.txt index bd0102bef1..9cfe4159f7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,776 @@ +ChangeLog: + +Cocos2d-x v3.8 @ September.6 2015 + + [NEW] spine: Supported Spine runtime 2.3 (Both native and web engine) + [NEW] Animate: Added Animate's getCurrentFrameIndex function + [NEW] network: Upgrade SocketIO support to v1.x + + [REFINE] web: Avoid re-bake the content when the parent node's position get changed + [REFINE] web: Added GameNodeObjectData and GameLayerObjectData in JSON parser + [REFINE] web: Updated skeleton animation to the latest version + [REFINE] web: Optimized resources automatic loading in JSON parser + [REFINE] web: Avoid cc.loader resource loading being terminated while encounter errors + [REFINE] web: Throw new Error object instead of error message string + [REFINE] web: Move setDepthTest to renderer + [REFINE] web: Added BlendFuncFrame parser + [REFINE] web: Permitted webp image loading on Chrome + [REFINE] web: Suspended the video player when the browser is minimized + + [FIX] web: Fixed a bug that VideoPlayer remove event throw error + [FIX] web: Fixed Armature position error in studio JSON parser + [FIX] web: Fixed default clearColor error in director + [FIX] web: Fixed rotation value parsing error in the timeline parser + [FIX] web: Fixed a bug that nested animation may be affected by outer animation + [FIX] web: Made LabelAtlas ignoring invalid characters and updating correctly the content size + [FIX] web: Fixed a bug that VideoPlayer remove event throw error + [FIX] web: Fixed a bug that cc.director.setNotificationNode(null) doesn't take effect + [FIX] web: Fixed texture rect update issue while changing sprite frame + [FIX] web: Fixed effect issue in ActionGrid and NodeGrid + [FIX] web: Fixed logic issue in Menu's _onTouchCancelled function + [FIX] web: Fixed MenuItem crash when normal image is null + [FIX] web: Fixed incomplete fadeout effects + [FIX] web: Fixed issue that return value of cc.screen.fullScreen is not boolean + [FIX] web: Fixed a bug that SkeletonNode is not drawing children + + [TEST] web: Rewrote testcase for stencil depth mask in RenderTextureTest + [TEST] web: Improved renderTexture stencilDepth test + [TEST] web: Fixed abnormal effects in effectsTest + [TEST] web: Fixed invisiable testcase of effects + +Cocos2d-x v3.7.1 @ August.12 2015 + [HIGHLIGHT] studio: Added new skeleton animation support and JSON parser for cocos v2.3.2 beta + + [NEW] Node: Added getNodeToParentTransform with selected ancestor + [NEW] web: Added cc.director.setClearColor and support transparent background + [NEW] web: Added Animate's getCurrentFrameIndex function + + [REFINE] studio: Optimized JSON parser's performance by removing audio play + [REFINE] studio: Optimized editor related extension data to a component instead of hosting in _userObject + [REFINE] web: Improved color/opacity manipulations in MenuItems + + [FIX] studio: Fixed ccs.Skin construction issue in JSON parser + [FIX] web: Fixed an issue that loading process won't trigger callback problem + [FIX] web: Fixed a bug where not resetting cc.Audio._ignoreEnded when replaying a sound caused it to stay in a "playing" state + [FIX] web: cc.ScrollView and cc.TableView: added check for parent visibility in onTouchBegan method + [FIX] web: Fixed TurnPageDown effect + [FIX] web: Fixed Cocos Studio parser issue that all elements are missing while the timeline action contains rotation + +Cocos2d-x v3.7 Final @ July 20 2015 + [REFINE] web: Add compatible Uint16Array definition + + [FIX] web: Fixed url check regular expression not supporting localhost issue + [FIX] web: Fixed issue that sprite doesn't update texture rect correctly + +Cocos2d-x v3.7 RC1 @ July 14 2015 + [REFINE] Improved localStorage warning when disabled + + [FIX] Fixed a bug that SingleNode's color isn't set + [FIX] studio: Fixed a bug of JSON parser that texture address is wrong + [FIX] Fixed MenuItems' color/opacity setter issue with child nodes + [FIX] Fixed page view's layout issue for JSON parser + [FIX] Add ttc loader and prevent the pure digital fonts is invalid + [FIX] Fixed Float32Array initialization + [FIX] Fixed a bug that layout background is missing + [FIX] Fixed a bug that ObjectExtensionData miss setCustomProperty and getCustomProperty function + +Cocos2d-x v3.7 RC0 @ July 1 2015 + +* The json loader of Cocos Studio will automatically load dependencies resources +* SIMD.js optimization for kazmath functions (from Intel) +* Deleted the redundant variables defined and log informations in ccui.RichText +* Allowed timeline animations with only one frame +* Improved property declaration of cc.Texture2D + +* Bug fixes: + 1. Fixed positionType error of particle system in timeline parser + 2. Fixed setAnimationName issue while the property is undefined in timeline parser + 3. Fixed `cc.TMXObjectGroup#objectNamed` not returning the result bug + 4. Fixed TransitionSlideX callback sequence issue + 5. Fixed issue in music end event + 6. Fixed bug that LayerColor's color will disappear when update transform after being baked + 7. Fixed `inverse` function bug of `cc.math.Matrix4` + 8. Fixed the webaudio's invalid loop attribute bug for chrome 42 + 9. Fixed crash when character not found into BMP font + 10. Fixed spine's js parser issue by avoid NaN duration + 11. Fixed LabelTTF multiline detection + 12. Fixed issue in ccui.Widget#getScale + 13. Fixed texture is not updated in some cases + 14. PlayMusic should not use the search path (timeline 2.x) + 15. Fixed bug of loading path of resources + 16. Premultiply texture's alpha for png by default to fix Cocos Studio render issues + 17. Fixed cache update issue of Layout after bake + 18. Fixed isBaked returning undefined issue + 19. Made CCProgressTimerCanvasRenderCmd to properly show colorized sprites + 20. Fixed attributes being reset issue while baked cache canvas' size changed + 21. Fixed texture does not rotate bug of ccui.LoadingBar + 22. Fixed color not being set issue in timeline parser + 23. Fixed custom easing animation bug + 24. Fixed return empty texture2d bug when adding image with same url multiple times + 25. Fixed actiontimeline can not step to last frame issue when loop play + 26. Fixed the prompt can not be used in iOS wechat 6.2 + 27. Fixed restoring of sprite's color issue + 28. Fixed Uint8Array initialize issue + 29. Fixed cc.TextFieldTTF Delegate memory leaks + 30. Fixed sorted result is wrong in cc.eventManager (_sortEventListenersOfSceneGraphPriorityDes) + 31. Fixed BinaryLoader issue on IE11 + 32. Fixed the sprite's texture bug when frequently change the color + 33. Fixed an issue that action will result in automatic termination + 34. Fixed ScrollView initWithViewSize issue + +Cocos2d-JS v3.6 @ April 29 2015 + +* Added GAF web runtime to the web engine, the native support will be merged in future version. +* Synchronised Cocos2d-x v3.6. + +* Bug fixes: + 1. Fixed a bug of Cocos Studio parser that it doesn't parse correctly the outline of text widget and button widget. + 2. Fixed a bug of Cocos Studio parser that it doesn't support inner action correctly. + 3. Fixed a bug of Cocos Studio parser that `ccui.Text`'s content size is set incorrectly. + 4. Fixed a bug of Cocos Studio parser that `ccui.Layout`'s background color is set incorrectly. + 5. Fixed a bug of `cc.Node`'s `removeAllChildren` that it doesn't notify the renderer to update. + 6. Fixed a bug of audio system that the resume of music may start from the beginning. + 7. Fixed a bug that sprite's `setTexture` fails to update its content size. + 8. Fixed a bug that Scale9Sprite's children doesn't get transformed recursively. + 9. Fixed constant naming issue of `ccs.FrameEaseType`. + 10. Fixed `cc.LoaderScene.preload` API inconsistency between web engine and native engine. + 11. Fixed a bug that `ccui.Slider` doesn't act correctly when it's scaled. + 12. Fixed a bug that `ccui.Button` renders incorrectly when scale9sprite option enabled. + 13. Fixed circular invocation issue in `cc.Sprite`'s canvas render command. + +Cocos2d-JS v3.6 Beta @ April 22 2015 + +* Improved TMX transform to support RotationX and RotationY. +* Refactored Spine skeleton render command. +* Added checks to prevent issues when `cc.Node.WebGLRenderCmd` is not exist. +* Improved iOS browsers detection. +* Added getter setter function for `cc.MotionStreak`'s stroke property. +* Improved the detection of render mode. +* Upgraded Action Timeline and parser for the latest version of Cocos editor. +* Added `enumerateChildren` function for `cc.Node`. +* Make `cc.Scale9Sprite` support unpreloaded texture. +* Added `cc.sys.isObjectValid` to detect whether an object is still valid (in web and native engine). + +* Bug fixes: + 1. Fixed a bug that `cc.Scheduler`'s `scheduleOnce` runs multiply times. + 2. Fixed a bug of `cc.Scheduler`'s `pauseAllTargetsWithMinPriority`. + 3. Fixed a bug of `cc.eventManager` that its event listeners' order is incorrect when some nodes haven't been added to the scene graph or have been removed from parent without cleanup. + 4. Fixed a bug of `cc.LabelTTF` that `enableShadow` doesn't work. + 5. Fixed a bug of `cc.LabelTTF` that `setColor` doesn't set shadow color under Canvas render mode. + 6. Fixed a bug that stopped audios can be resume after invoking pause on them. + 7. Fixed a bug that `ccui.LoadingBar`'s texture renders incorrectly without preload. + 8. Fixed a bug that cocos builder's callback doesn't get invoked. + 9. Fixed a bug that TMX objects' position is incorrect when content scale factor is modified. + 10. Fixed a mistaken usage of `cc.isObject` in `cc.Sprite` implementation. + 11. Fixed a bug that position type haven't been copied in `cc.ParticleSystem`'s `clone` function. + 12. Fixed some undefined parameter check issues in `cc.Node`. + 13. Fixed a bug that setter for `scaleY` of `cc.EditBox` is incorrect. + 14. Fixed a bug of `cc.SkeletonAnimation` that its canvas render command doesn't work correctly. + 15. Fixed a parsing issue for the width of `cc.LabelBMFont`. + 16. Fixed `ccs.TweenType`'s constants naming issue. + 17. Fixed a bug that the spine skeleton may be rendered under the unsupported mode. + 18. Fixed a bug when setting `cc.ParticleSystem`'s blend function in the ActionTimeline parser. + 19. Added check to prevent issues that functions may not exist in the ActionTimeline parser. + 20. Fixed a typo of `ccs.displayFactory`. + 21. Fixed a bug of `cc.Node.setPosition` that parameter check is incorrect. + +Cocos2d-JS v3.5 @ April 1 2015 + +* Upgraded Cocos Studio parser to support Cocos Studio v2.2. +* Upgraded Spine support to v2.1, added spine test case with FFD. FFD is supported in native but not in web, both engine can parse the new version file correctly, but the web engine will ignore FFD informations. +* Replaced '==' with '===' for better performance. +* Added `path` parameter in `ccs.load` to support modifying cocostudio project resource path. +* Added animationList to Cocostudio ActionTimeline to support playing animation by name. +* Made ParticleSystem support creation from an map object. +* Added missing functions to `cc.Grid3D` and `cc.PageTurn3D`. +* Added tip message functions to `cc.TextFieldTTF` for mobile browser. +* Added a function `cc.sys.openURL`. +* Disabled retina display by default for better performance. +* Added Bower support. +* Updated `cc.sys.OS_XXX` informations for supported systems. + +* Bug fixes: + 1. Fixed a bug of chipmunk.js that it doesn't work under closure compiler advanced mode. + 2. Fixed a bug of Cocos Studio parser that widget didn't set its layout component. + 3. Fixed grammatical mistakes in cocostudio parser logs. + 4. Fixed memory leak issue in `cc.LabelBMFont`. + 5. Fixed a bug of `cc.Scale9Sprite` that its `updateDisplayColor` doesn't take effect. + 6. Fixed a bug of Cocos Studio parser that `cc.Scale9Sprite` doesn't display correctly if its texture isn't preloaded. + 7. Fixed a bug of `cc.MenuItemSprite` that the construction will fail when parameter `selectedSprite` is a Scale9Sprite instance. + 8. Fixed a bug of Cocos Studio parser that the background color of `ccui.Layout` can't be parsed correctly. + 9. Fixed a bug of `cc.ClippingNode` that it doesn't work when set `inverted` to true in Canvas Mode. + 10. Fixed a bug of `ccs.Armature` that its name was modified to animation name when loading from json files. + 11. Fixed a bug of `ccui.PageView` that it cancel child touch during movement of page view. + 12. Fixed a bug of `cc.Scheduler` that its parameter `repeat` is invalid in schedule function. + 13. Fixed a bug of `cc.Scheduler` that `unschedule` function may fail. + +Cocos2d-JS v3.4 Beta0 @ March 19 2015 + +* Added Windows Phone 8.0 platform support. +* Upgraded SpiderMonkey to v33, greatly improved JS object garbage collection and performance. +* Bound 3D modules including camera, light, sprite 3d, animation 3d, billboard, etc. +* Improved `cc.FontDefinition` & `ccui.RichText` in the web engine. +* Added gradient stops feature to `cc.LayerGradient` [Web exclusive]. +* Upgraded `cc.Scheduler` in the web engine with Cocos2d-x v3.4 implementation. +* Added a loading screen when scripts are loading. +* Improved performance by replacing `Object.defineProperties` with `cc.defineGetterSetter`. +* Supported loading sprite frames from json object. +* Refactored math library to improve web engine performance. +* Removed some variables from `cc` namespace to improve web engine performance. +* Added the Firefox OS Web manifest to support Firefox OS apps. +* Added `cocos` attr to the script element in templates. +* Moved loading.js to res folder for Cocos Console release mode. + +* Bug fixes: + 1. Added `getSpriteFrame` to `cc.Sprite` to fix API inconsistency. + 2. Added `getObejct` to `cc.TMXObjectGroup` to fix API inconsistency. + 3. Added `addImageAsync` to `cc.textureCache` to fix API inconsistency. + 4. Fixed a bug of `cc.text` that its default font name is incorrect. + 5. Fixed a bug of `ccui.PageView` that its `getPage` doesn't work. + 6. Fixed a bug of `ccui.ImageView` that its `loadTexture` doesn't work while it's invoked multiple times at the same frame. + 7. Fixed a bug of `ccui` that its load event callbacks have some mistakes. + 8. Fixed a bug of `cc.Layer` that its bake function doesn't work when the layer has a parent node. + 9. Fixed typos in `cc.ClippingNode.WebGLRenderCmd` and `cc.ParticleSystem.WebGLRenderCmd` creation. + 10. Fixed a bug of `cc.Sprite` in `setTextureRect`. + 11. Fixed a bug of `cc.Screen`. + 12. Fixed a bug of `cc.view` that it doesn't work on iOS 8.1.2. + 13. Fixed a bug of cc.DrawNode that its lineWidth is always to default value when set linewidth to zero. + 14. Fixed a bug in hack for particles performance on canvas. + 15. Fixed a bug of `cc.audioEngine` that it doesn't work after minified/compiled. + 16. Fixed a bug in `CCBoot.js` that WebGL is not activated in web view of iOS 8. + 17. Fixed a bug of `cc.CheckBox` that its position is incorrect when its texture isn't preloaded. + 18. Fixed a bug of `cc.TMXLayer` that it stops to work after `setTileGID` called. + 19. Fixed a bug of Cocos parser 2.x that it doesn't set widget's LayoutComponent. + 20. Fixed a bug of `cc.isObject` that it considered function as an object. + +Cocos2d-JS v3.3 @ Feb.9, 2015 + +* Upgraded spine runtime to support the latest version and updated its test case. +* Added an option "noCache" for debugging on browsers. +* Set the default value of `cc.ParticleSystem`'s draw mode to texture mode. +* Added message to `ccs.load` when loading armature json file. +* Improved particle system test case. + +* Bug fixes: + 1. Fixed a bug of `cc.Sprite` that its `setSpriteFrame` doesn't work when sprite frame's `rotated` property is true. + 2. Fixed a bug of `cc.ClippingNode` when its stencil is `cc.Node` object in canvas mode. + 3. Fixed a ccui bug that the position of widgets is incorrect after loaded v2.x json file with `ccs.load`. + 4. Fixed a bug of `cc.PhysicsSprite` that `setIgnoreBodyRotation` function doesn't work. + 5. Fixed a bug of `ccui.Button` that setting pressed texture doesn't work when scale9 enabled. + 6. Fixed a bug of `ccui.ScrollView` that its `dir` property is null when passing `DIR_NONE` as `direction` in `_endRecordSlidAction` function. + +Cocos2d-JS v3.3 RC0 @ Feb.1, 2015 + +* Added web exclusive functions: `_getFontStyle`, `_setFontStyle`, `_getFontWeight` and `_setFontWeight` APIs to `cc.LabelTTF`. +* Observed orientation change event on mobile for resolution policy adaptation. + +* Bug fixes: + 1. Fixed Cocos Studio JSON parser's issues for parsing nested animation. + 2. Fixed Cocos Studio JSON parser's parameters parsing issues. + 3. Fixed Cocos Studio JSON parser's issue for parsing layer. + 4. Fixed Cocos Studio JSON action parser's issues. + 5. Fixed Cocos Studio JSON parser's issue for parsing Scale9Sprite. + 6. Fixed Cocos Studio JSON parser's issues caused by parsing process order. + 7. Fixed Cocos Studio JSON parser's issue for parsing loading bar's direction. + 8. Fixed UI layout system issues. + 9. Fixed `cc.EditBox`'s position issue under certain resolution policies. + 10. Fixed `ccui.ListView`'s issue for setting direction. + 11. Fixed an issue of `cc.Tween` that its `_currentPercent` is incorrect in `updateHandler` function. + 12. Fixed an issue of `ccui.Button` that its state is incorrect in `_onPressStateChangedToNormal`. + 13. Fixed an issue of `cc.ArmatureAnimation`'s `setMovementEventCallFunc`. + 14. Fixed an issue of `cc.Sequence` action when it's repeated. + 15. Fixed `_anchorPointInPoints` usage issue. + 16. Fixed an issue of `cc.GLProgram` that it doesn't work on some devices which didn't support highp float precision. + 17. Fixed an issue of fade actions that they don't work when duration is 0. + 18. Fixed `onended` callback issue of audio engine on iOS. + 19. Fixed Cocos Builder's parser issue for auto playing animations. + 20. Added a message to `ccs.Armature` that it doesn't support adding widget as its child. + 21. Improved test cases for stability. + +Cocos2d-JS v3.3 Beta @ Jan.24, 2015 + +* Added Cocos Studio v2.x parser and refactored 1.x parser. +* Upgraded new flow layout UI system in web engine. +* Refactored `load` events of texture2d, sprite and so on to be more intuitive. +* Added JavaScript file loader. +* Allowed set texture to null in `cc.Sprite`. +* Added full test cases for Cocos Studio v2.x parser and the new flow layout UI system. +* Upgraded MoonWarriors sample's UI and graphic design. + +* Bug fixes: + 1. Fixed a bug of Cocos2d UI, their focus event has been supported. + 2. Fixed a buf of `ccui.Widget` that its percent position doesn't work. + 3. Fixed a bug of `ccs.Armature` that its position doesn't update in visit on WebGL render mode. + 4. Fixed a bug of `cc.Sprite` that its `setTextureRect` function doesn't work when `setColor` invoked. + 5. Fixed a bug of `cc.PhysicsSprite` that its position is incorrect. + 6. Fixed a bug of `ccs.Bone` that its `setOpacity` and `setColor` doesn't work. + 7. Fixed a bug of `cc.LabelBMFont` that its word wrap doesn't work. + 8. Fixed a bug of `cc.sys` that it gets the incorrect OS type when system is Linux. + 9. Fixed a bug of `cc.audioEngine` that its loading path is incorrect. + 10. Fixed a bug of `ccui.Widget` that it can't touch when it's reused. + 11. Fixed a bug of UI system that the `setNormalizedPosition` doesn't work. + 12. Fixed a bug of `cc.ActionInterval` that its `_times` conflict with `cc.Blink`. + 13. Fixed release texture issue in canvas mode. + 14. Fixed a bug of `ccs.actionManager` that its `getActionByName` doesn't work. + 15. Fixed a bug of `cc.Sprite` that it can't draw without texture on WebGL mode. + 16. Fixed a bug of `cc.audioEngine` that it doesn't work on baidu browser. + 17. Fixed a bug of `cc.EditBox` that its position is incorrect on Canvas Mode and its string value is wrong when PlaceHolder is showing. + 18. Fixed a bug of `cc.loader` that its `loadImg` function doesn't work when image is accessed cross origin. + 19. Fixed a bug of `ccui.TextField` that its `contentSize` is incorrect in text field event. + +Cocos2d-JS v3.2 @ Dec.29, 2014 + +* Replaced `transform` function with `setTransform` function under canvas render mode for better performance. +* Added a timer in `cc.audioEngine` to check audio element loading event, prevent the loading process being stucked when load audio file failed. +* Added some new browser types to `cc.sys`. +* Added some audio resource loading codes to ensure compatibility with Wechat browser. +* Added check for WebAudio support to ensure compatibility. + +* Bug fixes: + 1. Fixed an issue that `cc.InputManager` doesn't trigger touch event on chrome mobile emulator. + 2. Fixed an issue that `cc.game.setFrameRate` doesn't work. + 3. Fixed an issue that `cc.view` can't remove resize event listener. + 4. Fixed an issue that `cc.EventManager` didn't set register flag to false when a listener is removed. + 5. Fixed an issue that `cc.audioEngine` doesn't play some audios on some iOS devices. + 6. Fixed an issue of ccui controls that their `setColor` doesn't work when cascade color is enabled. + 7. Fixed an issue that `ccs.Armature`'s `setColor` doesn't work in canvas render mode. + 8. Fixed an issue that `ccs.Armature` crashes when adding a child to it. + 9. Fixed an issue that `cc.SpriteBatchNode`'s status is incorrect in WebGL render mode. + 10. Fixed an issue of `cc.Layer` that its position is incorrect under bake mode. + 11. Fixed an issue of `ccui.RichText` that its `setContentSize` doesn't work. + 12. Fixed an issue of `cc.LabelTTF` that its `setColor` doesn't work when cascade color is enabled. + 13. Fixed an issue of spine that its skeletons position is incorrect when scaleX equals to -1 and scaleY equals to 1. + 14. Fixed `sp.Skeleton`'s API inconsistence by renaming `boundingBox` to `getBoundingBox`. + 15. Removed all usages of deprecated create functions in the test cases. + +Cocos2d-JS v3.2 RC0 @ Dec.11, 2014 + +* Refactoration of web engine by separating the render logic, the arthictecture level refactoration is now completed and brounght great performance improvement. +* Refactoration of web engine's resolution adaptation and audio engine with polyfilled adaptation logics for different devices and browsers. This ensures better compatibility and better extensibility for future needs. +* Added `setRotation` method to `ccui.ImageView`. +* Added a function that fill sprite with repeated texture in Canvas mode. +* Added `setLineHeight` method to `cc.LabelTTF`. +* Added `dumpAudioInfo` to `cc.audioEngine` for debugging purpose on mobile browser. +* Removed Cocos Studio's Protobuffer support from the framework. +* Added an outline shader sample. + +* Bug fixes: + 1. Fixed an issue of `cc.Sprite` that its rendering is incorrect without texture. + 2. Fixed an issue of `cc.ClippingNode` that its stencil drawing is incorrect on Canvas Mode. + 3. Fixed an issue of `TextFieldReader` that it will throw an error when 'areaWidth' and 'areaHeight' equal to zero. + 4. Fixed an issue of `ccui.CheckBox` that its getSelectedState doesn't return its state. + 5. Fixed an issue of `cc.LabelTTF` that it doesn't update the string when its string become to empty string. + 6. Fixed an issue of `cc.ParticleSystem` that it can't change its texture mode and shape type in Canvas mode. + 7. Fixed an issue of `cc.Layer`'s bake function that its position is incorrect when cc.view's scale isn't 1. + 8. Fixed an issue of `ccs.ArmatureAnimation`'s `setMovementEventCallFunc` and `setFrameEventCallFunc`. + 9. Fixed an issue of `console.log` that it isn't a function on IE9. + 10. Fixed an issue of `CSLoader` that it will add duplicate resources to sprite frame cache. + 11. Fixed an issue of `cc.ProgressTimer` that its setColor is not taking effect. + 12. Fixed an issue of `cc.loader` that it will throw an error when loading a remote texture. + 13. Upgrade html5 version chipmunk to the latest release. + +Cocos2d-JS-v3.1 @ Oct.22, 2014 + +* Released Facebook Integration for Cocos2d-JS v1.0, all APIs have been significantly polished and stabilized. Improved test cases for Facebook with more features demonstrated. +* Upgraded Cocos2d-x to v3.3 rc0 +* Supported Cocos Studio v2.0 including Timeline animation support and proto buffers format support for both web engine and JSB engine. +* Refactored load event of texture, sprite frame and sprite for better maintainability. +* Refactored `cc.rendererCanvas` for improving performance. +* Moved the `CC_Texture0` definition of fragment shader to cc.GLProgram to ensure compatibility with JSB. +* Added normalized position functions to cc.Node. +* Refactored the constructor of Cocos Studio's classes and deprecated all create functions. +* Refactored Cocos Studio reader for better maintainability. +* Improved Facebook SDK. +* Modified `cc.ProgressTo`'s behavior, its progression didn't reset to zero when the progression is 100. +* Changed `ccui.Widget`'s default anchor point to (0, 0) in widget reader. +* Removed all deprecated create function usage in engine and in the test cases. + +* Bug fixes: + 1. Fixed an issue of `cc.UILayout` that its scissor mode didn't work. + 2. Fixed an issue of `ccui.TextBMFont` that its 'string' property setting was incorrect. + 3. Fixed an issue of `cc.DrawNode` that its element's position was incorrect in Canvas mode. + 4. Fixed an issue of `cc.Layer` that its bake function didn't work in new renderer. + 5. Fixed an issue of `cc.Scale9Sprite` that its cached canvas size was incorrect. + 6. Fixed an issue of `cc.Director` that its position was incorrect when calling `setProjection` in new renderer. + 7. Fixed an issue of `cc.view` that the reinitialization logic of frame size was incorrect. + 8. Fixed incorrect usage of `cc.progressTo` in progress action test. + 9. Fixed an issue of CocosNodeTest for the new renderer. + 10. Fixed minor issues in test cases. + +* Known Issues: + 1. `jsb.AssetsManager` doesn't work on windows due to a bug in libcurl + +Cocos2d-JS v3.1 beta @ Oct.13, 2014 + +* Refactoration of the web engine with new renderer on the architecture level, optimization is under going. +* Released Facebook SDK for Cocos2d-JS beta2, its API have been significantly improved and stablized. +* Upgraded MoonWarriors sample with new set of graphical assets. +* Automatically enabled WebGL on iOS 8 safari. +* Upgraded chipmunk.js to the newest version. +* Supported setting color of shadow for `cc.LabelTTF`. +* Added `getTitleRenderer` function to ccui.Button. +* Supported Coco Studio timeline animation. +* Set the default value of LabelAtlas's `cascadeOpacityEnabled` and `cascadeColorEnabled` to true. +* Added a listener of texture to `cc.Sprite#setTexture` when the texture hasn't loaded. +* Activated `cc.pool` for all kind of objects. +* Added query test for chipmunk and added necessary JavaScript bindings. + +* Bugs fix: + 1. Fixed a bug of `cc.ComponentContainer` that a 'if' statement behavior is incorrect. + 2. Fixed a bug of `cc.Scale9Sprite` that the behavior of Canvas and WebGL is different. + 3. Fixed a bug of `cc.EventListener` that its pause state should set to true. + 4. Fixed a bug of `cc.ParticleSystem` that it should apply canvas scaling on canvas rendering mode. + 5. Fixed a bug of CCBoot.js that `cc.loader` should add a condition to check whether `crossOrign` property is undefined on IE9 and IE10. + 6. Fixed a bug of `ccui.Widget` that its `setPosition` function's behavior is incorrect. + 7. Fixed a bug of `ccui.LoadingBar` that its `barRenderer` should add to protected children array. + 8. Fixed a bug of `cc.Texture2D` that its `TEXTURE_MAG_FILTER` should set to LINEAR. + 9. Fixed a bug of `cc.TMXMapInfo` that its doesn't parse `rotation` property. + +Cocos2d-JS-v3.0 Final @ Sep.10, 2014 + +* Facebook SDK Beta2: Added `appRequest` API. +* Facebook SDK Beta2: Added permission request in `login` API, removed `requestPermission` API. +* Facebook SDK Beta2: Renamed `request` API to `api`. +* Facebook SDK Beta2: Renamed `publishInstall` API to `activateApp`. +* Added getter and setter function for browser's density dpi: `cc.view.setTargetDensityDPI`, `cc.view.getTargetDensityDPI`. +* Added some type check functions. +* Added audio support for wechat browser. +* Added setPlaceHolderColor and setTextColor to ccui.TextField. +* Added API reference for Cocos Studio extension. + +* Bugs fix: + 1. Fixed an issue of `cc.Menu` that its item's touch priority is different than cc.eventManager. + 2. Fixed an issue of `cc.view` that its NO_BORDER mode doesn't work correctly. + 3. Fixed an issue of `cc.LabelBMFont` that its content size is different than JSB. + 4. Fixed an issue of `cc.LabelBMFont` that its `setColor` is invalid on some mobile devices. + 5. Fixed an issue of `cc.PageView` that it can't receive TOUCH_CANCEL event. + 6. Fixed an issue of `cc.loader` that it can't load cross origin textures. + 7. Fixed an issue that Facebook SDK Web's `appRequest` wraps info parameter incorrectly. + 8. Fixed an issue of ccui widgets' `addEventListener` that it doesn't accept function's target as parameter. + +Cocos2d-JS-v3.0 RC3 @ Aug.29, 2014 + +* Facebook SDK Beta: Unified the callback parameters for different platform. +* Facebook SDK Beta: Added payment API on Web platform. +* Facebook SDK Beta: Supported app request and share open graph API on Web platform. +* Facebook SDK Beta: Remove plugin configuration for Facebook SDK to simplify the usage. +* Facebook SDK Beta: Added test case for new features and improve all test cases. +* Cocos Console: Improved web compile with `--advanced` tag. +* Improved Cocos2d-JS inline docs to provide a better API reference document. +* Refactored cc.game for maintainability. +* Refactored cc.async to simplify and improve the usage. +* Added `cc.formatStr` for string formatting, for example: `cc.formatStr("a: %d, b: %b", a, b)`. +* Refactored cc.log to support formatted string. +* Refactored cc.pool's `hasObj` to `hasObject` and `removeObj` to `removeObject`. +* Added some state check to cc.audioEngine. +* Refactored sprite's blend function to support more features on Canvas. +* Refactored `cc.textureCache.textureForKey` to `cc.textureCache.getTextureForKey`, `cc.TMXTilemap#propertiesForGID` to `cc.TMXTilemap#getPropertiesForGID` to follow the standard API naming style. +* Detected mouse event on touch screen tablets. +* Support new construction for cc.PhysicsDebugNode and deprecated `cc.PhysicsDebugNode.create` +* Made cc.Texture2D's setTexParameters supports two types of parameters. +* Added test case for remote image loading. + +* Bugs fix: + 1. Fixed an issue of tilemap that it can't runAction in canvas render mode. + 2. Fixed an issue of cc.eventManager that its removeListeners' codes are unreachable. + 3. Fixed an issue of cc.EditBox that its position is incorrect. + 4. Fixed an issue of cc.WebAudio that its stopped state is incorrect. + 5. Fixed an issue of cc.audioEngine that it doesn't work on firefox after it compiled with advanced mode. + 6. Fixed an issue of ccs.Bone that it doesn't update color and opacity correctly. + 7. Fixed an issue of ccs.Armature that its setShaderProgram doesn't work. + 8. Fixed cc.Sprite and cc.Scale9Sprite's issue so that their texture loads incorrectly. + 9. Fixed an issue of ccui.LoadingBar that its setPercent is invalid. + 10. Fixed an issue of Armature reader that it can't parse isTween property. + 11. Fixed an issue of ccui.PageView that its getTouchBeganPosition returns incorrect value. + 12. Fixed an issue of ccui.ImageView that its setColor doesn't work. + 13. Fixed an issue of cc.RenderTexture that it doesn't support parameter depthStencilFormat. + 14. Fixed an issue of ccs.ArmatureAnimation.setSpeedScale. + 15. Fixed an issue of cc.Scale9Sprite that it has a line on iOS device. + 16. Fixed CCProgressTimer draw on canvas with colorized sprite + 17. Fixed an issue of cc.game that its frameRate setter is invalid. + 18. Fixed an issue of cc.loader that its callback state is incorrect. + +Cocos2d-html5-v3.0 RC2 @ Aug.8, 2014 + +* Refactored Cocos UI for more stable and friendly user experience. +* Upgraded Cocostudio reader to support version 1.2 - 1.5.x. +* Upgraded Cocostudio Armature animation from Cocos2d-x v3.2. +* Added back 2.x createWithXXX functions and deprecate all create/createWithXXX functions. +* Merged cc.NodeRGBA and cc.LayerRGBA to cc.Node. +* Fixed ctor functions bugs to support new construction. +* Refactored cc.Sprite's setColor to improve its performance. +* Renamed CCAffineTransform.js's functions to lowercase started functions. +* Upgraded cc.Scale9Sprite from Cocos2d-x 3.2. +* Improved cc.LabelTTF's line break algorithms to support multi-languages. +* Made cc.RenderTexture's beginWithClear accept color value from 0-255. +* Improved implementation of all Actions lower case alias creation functions. +* Added lower case creation functions for 3d actions and progress actions. +* Added cc.sys.platform API for detecting platform. +* Upgraded HelloWorld project with v3.0 APIs. + +* Bugs fix: + 1. Fixed a bug of cc.WebAudio that sourceNode's playbackState is invalid on some browsers. + 2. Fixed a bug of cc.MenuItemToggle that callback is not correctly initialized when using new construction. + 3. Fixed a bug of ccui.Layout that its clipping area is incorrect. + 4. Fixed a bug of requestAnimFrame that it doesn't work after re-focus WeChat browser on Samsung mobile. + 5. Fixed a bug of CCBoot.js that bind function is undefined in Safari for iOS 5.1. + 6. Fixed a bug in cc.layer's bake function that its position is incorrect when cc.view is scaled. + 7. Fixed a bug of cc.LayerMultiplex. + 8. Fixed a bug of cc.TMXLayer that it can't display all map image when its type is hexagonal. + 9. Fixed a transform error in ccs.TransformHelp. + 10. Fixed a bug of cc.ControlSwitch. + 11. Fixed image format constant inconsistence. + 12. Fixed a bug of ccui.Widget that it is invisible after popScene. + 13. Correct behavior of cc.TransitionSlideInB and cc.TransitionSlideInT. + 14. Fixed bugs of ccui.Widget and ccui.Text's clone functions. + + +Cocos2d-html5-v3.0 RC0 @ July.3, 2014 +* Added Facebook SDK plugin into Pluginx extension. +* Refactoration of gui system `ccui` for better performance, usage and maintainbility. +* Added `bake` function to `cc.Layer` to support layer baking. +* Added object pool extension: `cc.pool`. +* Added new easing functions: bezier action, quadratic actions, quartic actions, quintic actions, circle actions, cubic actions. +* Made `cc.loader` continue the counter process even if a resource failed to be loaded. +* Supported multiple property objects in `cc.Class.extend` function. +* Refactored `ccui.Widget`'s `getLeftInParent`, `getBottomInParent`, `getRightInParent`, `getTopInParent` to `getLeftBoundary`, `getBottomBoundary`, `getRightBoundary`, `getTopBoundary`. +* Refactored `cc.FadeIn.create(duration, toOpacity)` to `cc.FadeIn.create(duration)`. +* Refactroed all string access functions in `ccui` extension to `setString` and `getString`. +* Added `getContentSize` and `setContentSize` in `ccui` extension. +* Changed the default alpha value of `cc.Color` from `undefined` to 255. +* Made `cc.log` support formatted string. + +* Bugs fix: + 1. Fix bugs on creating sequence objcet or spawn object using new method. + 2. Fix a bug that `ccui.LoadingBar`'s `setPercent` function will crash when its texture is in a plist file and scale9Enabled is true. + 3. Fixed a bug of `cc.audioEngine` that it crashs when audio isn't correctly loaded and its duration is infinity. + 4. Correction of the calculation of `cc.visibleRect`. + 5. Fix `cc.Skin`'s bounding box calculation for canvas rendering. + 6. Fix an issue that `cc.TextureCache` doesn't handle loaded texture in some case. + 7. Fix an issue that texture rect could be zero sized in `initWithFile` function of `cc.Sprite`. + 8. Fix a bug on inverted ClippingNode with DrawNode as stencil in Canvas render mode. + 9. Fix a bug that `cc.SpriteFrame` didn't support initialization with texture name parameter. + 10. Fix a bug on `ccs.ArmatureAnimation`'s loop parameter. + 11. Fix a bug that `cc.JumpTo`'s `_delta` position calculation is incorrect. + 12. Fix a bug of `cc._audioLoader` that it doesn't work when it failed to load an audio file. + +Cocos2d-html5-v3.0 beta @ May.23, 2014 + +* Refactored actions to make it more friendly and easy-to-use. +* Integrated Spine skeleton animation feature. +* Renamed constants of ProgressTimer, Scale9Sprite, TMXLayerInfo, Node, ParticleSystem for maintainability. +* Modified mouseMove event behavior of cc.inputManager to compatible with Cocos2d-x +* Modified cc.game.run to receive a canvas id as parameter. +* Added local audio file playing from 'file://' origin. +* Added local images file displaying from 'file://' origin. +* Refactored cc.TMXLayer's setTileAt etc functions to support point or x,y as their parameters. +* Added a check to cc.Sprite and cc.SpriteFrame to avoid its texture rect out of bounds. +* Added a check to cc.SpriteFrame to avoid cc.loader release invalid sprite frame file. +* Made cc.Touch return copies of point. +* Made the default of cc.Color alpha value is 255 to avoid cc.Sprite's setColor is invalid. +* Optimized cc.Node.sortAllChildren for better performance. +* Added warning of cc.Texture2D if it has an invalid texture. + +* Bugs fix: + 1. Fixed a bug of cc.winSize that it returns incorrect value when using setDesignResolution. + 2. Added a check to cc._setup to avoid double invocation. + 3. Fixed a bug of cc.TMXMapInfo that its tile's property id is incorrect. + 4. Fixed a bug of cc.Scale9Sprite that its CascadeColor and CascadeOpacity are invalid. + 5. Fixed a bug of ccs.UILoadingBar which its barRendererScaleChangedWithSize is incorrect. + 6. Added some forgotten files to build.xml for minimize core. + 7. Corrected a mistake of renderMode default value in CCBoot.js. + 8. Fixed a bug of ccui.Layout's draw function that its scaleX, scaleY value is incorrect. + 9. Fixed a bug of cc.Audio's stopMusic function. + 10. Fixed a bug of TextureCache that it can't remove image's event handler. + 11. Fixed ClippingNode's DrawNode stencil bug on Canvas. + 12. Fixed a typo 'cc.radiansToDegress' function to 'cc.radiansToDegrees'. + 13. Fixed a bug of ccui.ImageView that its setSize is invalid when the picture without pre-load. + 14. Fixed a bug of cc.ParticleSystem that it throws a error when create from CocosBuilder. + 15. Fixed a bug of cc.LabelAtlas that it can't display its children. + 16. Fixed a bug of cc.fontLoader that it can't load custom font. + 17. Fixed a bug of ccui.Widget that its setOpacity is invalid. + 18. Fixed a bug of cc.Node that it transform value is incorrect when a node skew to a special value. + +Cocos2d-html5-v3.0 alpha2 @ April.14, 2014 + +* Minimized the size of core from 254k to 113k after google closure advanced compiling +* Made cc.DrawNode support some DrawingPrimitive's drawing function on WebGL mode +* Added undefined checking in cc.loader for better performance. +* cc.Sprite supports creating a sprite through external URL. +* Added the warning information to notice developers that their project.json cannot be loaded or parsed. +* Added retina display support to cc.Editbox. +* cc.Node's pauseSchedulerAndActions and resumeSchedulerAndActions are deprecated, please use pause and resume instead. +* Added render mode checking to 3D action classes. +* Added SocketIO +* Sync cc.eventManager to the latest version of Cocos2d-x v3.0 Stable. +* ccui.Layout's doLayout function has been set to private function "_doLayout" +* Made actions extendable directly via ctor +* Added null callback check in cc.textureCache.addImage +* Fixed the API inconsistence of ccs.ArmatureAnimation.play +* Fixed compatibility and performance for ctor +* Renamed all Uppercase functions to lowercase in CCMacro +* Added necessary GL constants in H5 +* Fixed CONSTANTS inconsistence between h5 and JSB + +* Bugs fix: + 1. Fixed ccs.comAttribute API incompatible issue + 2. Fixed a bug of Cocostudio's data reader that getting isTween value is incorrect when the attribute value is false. + 3. Fixed a bug of Sprite that it doesn't work when its texture doesn't preload and its parent is a SpriteBatchNode + 4. Fixed a bug in CCBoot.js that console.error is invalid on firefox. + 5. Fixed some comment errors of framework. + 6. Fixed a bug of cc.LabelBMFont that it's multiline works incorrectly. + 7. Fixed a bug that Touches event doesn't work in release mode on IE browser. + 8. Fixed a bug that cc.winSize has not been reset after cc.view.setDesignResolutionSize. + 9. Fixed typo in ccui.Widget.TOUCH_BEGAN + 10. Fixed a bug of cc.MenuItemSprite.create that + 11. Fixed a bug of cc.loader that it need to set value before call the callback. + 12. Fixed a bug of cc.log that it doesn't work in IE9 + 13. Fixed IE incompatible issue with __lookupGetter__ + 14. Fixed a mistake of cc.Node that it return a reference of _position in getPosition + 15. Fixed a bug of cc.ClippingNode that its _super is undefined + 16. Fixed a bug of inputManager's touch event in IE browser + +* Known Issues: + 1. EventListener is not extendable. + + +Cocos2d-html5-v3.0 alpha @ March.15, 2014 + +* Refactor some properties of all rendering classes with getter setter for providing javascript user friendly APIs. +* Provide `attr` function for cc.Node and its descendants to permit modify multiple properties at the same time with a key-value object. +* Refactor foundational data structures for better maintainability. +* Add event manager to cocos2d-html5, all events are dispatched via cc.eventManager to event listener. +* Refactor cc.Application to cc.game. +* Refactor singleton Classes to javascript object. +* Refactor all createWithXXX functions into unified create function with different parameters. +* Use `moduleConfig.json` to config the paths of engine scripts. +* `cocos2d.js` is replaced with `project.json`. +* Refactoring cc.loader. +* CocoStudio GUI updated to 3.0, and ccs prefix of UI widgets have been changed to ccui. +* CocoStudio v1.3.0 has been supported in v3.0. +* richText has been supported in v3.0. +* Use `cc.BuilderReader.registerController` to register controller of ccb. +* Add `cc.path` to handle operations of file path. +* Add `cc.async` to handle async operations. +* Add cc.NodeGrid in v3.0. +* Replace `replaceWithScene` and `runWithScene` with `runScene`. +* move sys.xxx to cc.sys.xxx. +* Refactor CCEGLView.js for better maintainability. +* Refactor CCScheduler.js for better maintainability. +* Remove arguments.callee which is forbidden in ECMAScript strict mode. +* Refactor Array clean function for better performance. +* Refactor some functions about array operation. +* Refactor FadeIn/FadeOut to fix a bug that it always start from/to 255. +* Rewrite functions in CCNS.js with regex. +* Move CCFormatHelper and CCNS content into CCCommon.js. +* Refactor cc.Screen to support all browsers. +* Add retina display support for Apple devices to cc.view. +* Add "allLayers" function to cc.TMXTiledMap. +* Make cc.p and cc.size support two types of parameters. +* cc.DrawNode supports all functions of cc.DrawingPrimitive on Canvas mode. +* WebAudioEngine is supported on iOS now. +* Use event on cc.canvas to make full screen. +* Add a browser white list that support multiple audio playback at the same time. +* Removed in/hasOwnProperty usage in engine for better performance. +* Refactoring CCCommon.js, delete some unused functions, rename some functions for better maintainability. +* Add analytics plugin protocol ,Flurry plugin and ProtocolAds.js plugin protocol. +* Arguments length check replaced by undefined check for better performance. +* Fix legacy Function.prototype.bind support. + +* Bugs fix: + 1. Avoid CCLabelTTF enter in infinite loop while character's width larger than the dimension width + 2. Add jsDoc Flags to cc.NodeRGBA and cc.LayerRGBA + 3. Fixed a bug that Schedule doesn't restart when widget is re-added after being removed + 4. Correction of split logic in CCLabelTTF + 5. Fixed a bug that armature animation does not display correctly on canvas mode + 6. Correct gui widget clone functions + 7. Fixed a bug of cc.SpriteFrameCache that filePath is needed in `loadedFileNames` + 8. Add a condition check to avoid texture out of range bug + 9. Fixed a bug of cc.Editbox that its position is incorrect when its parent node isn't root node. + 10. Fixed a SimpleAudioEngine's state error. + 11. Fixed a bug of cc.TMXTileMap that its `_tileProperties` should be a dictionary object + 12. Fixed a bug of cc.DrawNode that it need to deep-copy verts in `drawPoly` + 13. Fixed a bug of UILabelBMFont that variable `_strStringValue` should be `_stringValue` + 14. Fixed a bug in SceneReader's `setPropertyFromJsonDict` function + 15. Fixed a bug when margin not set in ccs.Margin + 16. Fixed a bug of cc.TMXLayer that its `removeChild` works incorrectly. + +* Known Issues: + +Cocos2d-html5-v2.2.2 @ Dec.31, 2013 +* Resolution policy now act as a combination of cc.ContainerStrategy and cc.ContentStrategy so that user can beautifully customize its behavior. +* cc.LabelTTF's now support perfectly automatic line break with occidental and Chinese characters. +* cc.ClippingNode for canvas render mode is implemented. +* Refactored cc.Node and cc.Sprite by adding cc._PointConst and cc._SizeConst for better Performance. Now the performance of setPosition and getPosition is faster 65% than before. +* CCNode's setContentSize and setAnchorPoint support two types of parameters, more friendly and more efficient. setAnchorPoint(x,y) is faster 35% than setAnchorPoint(cc.p(x,y)). +* Added NPM support and adjusted folder structure. It supports modules customization, the mini HelloWorld is just 185KB when package all files into single file.Please visit NPM Guide for more details. +* Added SpriteFrameCache JSON format support. +* Added source map generating of Closure Compiler advance mode , please make sure your JDK version is 7.0 and up. +* Improved audio compatibility for mobile browser, added playing queue to solve the one audio restriction of some mobile browser. +* Refactoring TMXLayer for better performance. +* set cc.Rect's origin and size from public to private for compatibility with JSB. +* CocoStudio supports async image loading. +* cc.log supports printing object content to console +* Refactoring indexing of actionManager and Scheduler for better performance. +* ClippingNode supports some features on Canvas Mode. +* Migrated Armature to v2.2.2. +* Add callback function to CocoStudio action completion and refactoring it for better performance. +* CCBReader supports that CCControl can send action by all types of event. +* Add create function to cc.NodeRGBA +* Add jsdoc document to CocoStudio classes + +* Bugs fix: + 1. Fixed a bug of TMXLayer that it has thin lines at tile's border when EGLView's scale doesn't equal 1. + 2. Fixed bugs of LabelBMFont about updateDisplayedOpacity and multi-line is incorrect. + 3. Fixed a bug of LabelTTF that enter an infinite loop when setting special string and fontSize to it. + 4. Fixed a bug of NodeRGBA and LayerRGBA about updateDisplayedColor and updateDisplayedOpacity. + 5. Fixed a bug of ProgressTimer that it can't change color and opacity when calling setColor and setOpacity directly. + 6. Fixed a bug of cc.ProgressTimer that it has a blink when its reverseDirection equals false and type equals cc.PROGRESS_TIMER_TYPE_RADIAL. + 7. Some Loaders need modify their default value to adapt CocosBuilder that CocosBuilder ignores some two properties object like cc.Point when all the properties equals to zero. + 8. Fixed a bug of Fixed a bug of TMXTileMap that its getProperty doesn't work. + 9. Fixed a bug of ActionInterval that it throws error when its target doesn't have RGBAProtocol property. + 10. Fixed a bug of MenuItemSprite that it throws an error when create a MenuItemSprite object with cc.Node. + 11. Fixed a bug of UIWidget that its container intercept touch event while they can't. + 12. Fixed a bug of ccs.UILayout about relative positioning. + 13. Fixed a bug of Armature that its nodeToParentTransformCanvas correct. + +* Known Issues: + 1. Effect Advanced Lens3D doesn't work + 2. ClipNodeTest effects varies in different browsers + 3. Stencil of cc.ClippingNode doesn't work well with WEBGL render mode, the stencil have the right size and shape but it masks the content with a monochrome mask. + +Cocos2d-html5-v2.2.1 @ Nov.19, 2013 +* CocoStudio is now supported on Cocos2d-html5. The GUI, scene and component modules have been added to it. +* cc.EGLView and most render classes have been re-written to adapt multiple resolution resources in-order to optimize performance on mobile browsers. +* Refactored cc.LabelTTF, now its contentSize and position is correct for labels which has defined stroke and shadow. +* Corrected the behavior of "CascadeColorEnabled" and "CascadeOpacityEnabled" for cc.NodeRGBA and cc.LayerRGBA. +* All cc.Assert has being replaced, and more arguments checking and log information have added to engine's function. +* Added cc.Screen to engine, it uses to enter/exit FullScreen mode. +* Added cc.VisibleRect to engine, it provides nine points of game view for positioning. +* cc.WebAudioEngine now works perfectly on chrome. +* CocoStudio's namespace changes to 'ccs' now, and the other module's namespace will be renamed and support NPM in next version. +* cc.rect now accepts more types of parameters on JSB and HTML5 now, for example: cc.rect(1,1,1,1) and cc.rect(aRect), and cc.rect(cc.p(1,1),cc.size(10,10)); +* Optimized cc.Node's getBoundingBoxToWorld for better Performance. +* Modified the _sequenceCompleted method in CCBAnimation, it can set the next sequence in callback now. +* Improved the maintainability for _drawSceneForWebGL and _drawSceneForCanvas. +* ParticleExamples has been refactored for JSB. +* HelloHTML5World's CircleSprite has been removed, because it doesn't work on JSB. + +* Bugs fix: + 1. Fixed a Scale9Sprite's bug that setCapInsets is invalid. + 2. Fixed a bug that prevents the game to run on Chrome 31 WebGL mode. + 3. Fixed a bug of LabelTTF that doesn't work on Baidu browser. + 4. Fixed a bug of Sprite that it shouldn't to set transform dirty when setting color or opacity. + 5. Fixed a bug that cc.EditBox's setFontSize is invalid. + 6. Fixed a bug that Particles doesn't work when search path in FileUtils was set. + 7. Fixed a bug of Scale9Sprite that it throws an error when _scale9Image is null. + 8. Fixed a bug of LayerGradient that it shows wrong size when setting content size. + 9. It should listen to the method "onLoad" in cc.FileUtils when the browser isn't IE. + +* Known Issues: + 1. Effect Advanced Lens3D doesn't work + 2. ClipNodeTest effects varies in different browsers + Cocos2d-html5-v2.2 @ Sep.19, 2013 * Improved Sprite, Node, LabelTTF class define from separated code to combined code for maintainability, now it is clean and clear * added a new sample game "Fruit attack" which works great on PC browsers, mobile browsers, and can even be run natively as an android and iOS app with JSB diff --git a/CocosDenshion/SimpleAudioEngine.js b/CocosDenshion/SimpleAudioEngine.js deleted file mode 100644 index 098dcdc7a2..0000000000 --- a/CocosDenshion/SimpleAudioEngine.js +++ /dev/null @@ -1,1433 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -var cc = cc || {}; - - -/** - * A simple Audio Engine engine API. - * @class - * @extends cc.Class - */ -cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{ - _audioID:0, - _audioIDList:null, - ctor:function(){ - this._audioIDList = {}; - }, - /** - * Check each type to see if it can be played by current browser - * @param {Object} capabilities The results are filled into this dict - * @protected - */ - _checkCanPlay: function(capabilities) { - var au = document.createElement('audio'); - if (au.canPlayType) { - //