Skip to content
Browse files

Merge pull request #2875 from cocos2d/develop

Cocos2d-JS v3.6
  • Loading branch information...
2 parents 401d602 + bd519ee commit 6736da18cf50f5cefffd72e1ece015bd9fa218ba @pandamicro pandamicro committed May 1, 2015
Showing with 3,331 additions and 1,717 deletions.
  1. +1 −0 .gitignore
  2. +39 −6 AUTHORS.txt
  3. +217 −119 CCBoot.js
  4. +5 −5 CCDebugger.js
  5. +200 −0 CHANGELOG.txt
  6. +11 −2 README.mdown
  7. +37 −0 bower.json
  8. +3 −3 cocos2d/actions/CCAction.js
  9. +3 −3 cocos2d/actions/CCActionCatmullRom.js
  10. +7 −7 cocos2d/actions/CCActionEase.js
  11. +1 −1 cocos2d/actions/CCActionInstant.js
  12. +37 −21 cocos2d/actions/CCActionInterval.js
  13. +49 −6 cocos2d/actions3d/CCActionGrid.js
  14. +2 −2 cocos2d/actions3d/CCActionGrid3D.js
  15. +13 −1 cocos2d/actions3d/CCActionPageTurn3D.js
  16. +8 −8 cocos2d/actions3d/CCActionTiledGrid.js
  17. +60 −26 cocos2d/audio/CCAudio.js
  18. +1 −1 cocos2d/clipping-nodes/CCClippingNode.js
  19. +4 −4 cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js
  20. +24 −12 cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js
  21. +3 −3 cocos2d/compression/base64.js
  22. +20 −20 cocos2d/compression/gzip.js
  23. +12 −11 cocos2d/core/CCActionManager.js
  24. +11 −19 cocos2d/core/CCCamera.js
  25. +18 −13 cocos2d/core/CCDirector.js
  26. +17 −26 cocos2d/core/CCDirectorWebGL.js
  27. +1 −1 cocos2d/core/CCDrawingPrimitivesCanvas.js
  28. +3 −3 cocos2d/core/CCDrawingPrimitivesWebGL.js
  29. +555 −263 cocos2d/core/CCScheduler.js
  30. +1 −1 cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js
  31. +4 −3 cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js
  32. +211 −32 cocos2d/core/base-nodes/CCNode.js
  33. +43 −41 cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js
  34. +11 −11 cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js
  35. +24 −15 cocos2d/core/cocoa/CCAffineTransform.js
  36. +3 −3 cocos2d/core/cocoa/CCGeometry.js
  37. +28 −2 cocos2d/core/event-manager/CCEvent.js
  38. +1 −1 cocos2d/core/event-manager/CCEventExtension.js
  39. +51 −8 cocos2d/core/event-manager/CCEventListener.js
  40. +46 −34 cocos2d/core/event-manager/CCEventManager.js
  41. +84 −25 cocos2d/core/labelttf/CCLabelTTF.js
  42. +32 −18 cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js
  43. +3 −2 cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js
  44. +95 −16 cocos2d/core/layers/CCLayer.js
  45. +46 −41 cocos2d/core/layers/CCLayerCanvasRenderCmd.js
  46. +103 −40 cocos2d/core/layers/CCLayerWebGLRenderCmd.js
  47. +4 −4 cocos2d/core/platform/CCClass.js
  48. +36 −15 cocos2d/core/platform/CCCommon.js
  49. +1 −1 cocos2d/core/platform/CCConfig.js
  50. +34 −11 cocos2d/core/platform/CCEGLView.js
  51. +6 −6 cocos2d/core/platform/CCInputExtension.js
  52. +3 −3 cocos2d/core/platform/CCInputManager.js
  53. +8 −1 cocos2d/core/platform/CCLoaders.js
  54. +2 −2 cocos2d/core/platform/CCMacro.js
  55. +13 −13 cocos2d/core/platform/CCSAXParser.js
  56. +78 −76 cocos2d/core/platform/CCScreen.js
  57. +35 −1 cocos2d/core/platform/CCTypes.js
  58. +281 −282 cocos2d/core/platform/CCTypesWebGL.js
  59. +1 −1 cocos2d/core/platform/miniFramework.js
  60. +2 −2 cocos2d/core/renderer/RendererCanvas.js
  61. +9 −4 cocos2d/core/scenes/CCLoaderScene.js
  62. +1 −1 cocos2d/core/sprites/CCAnimationCache.js
  63. +84 −43 cocos2d/core/sprites/CCSprite.js
  64. +8 −8 cocos2d/core/sprites/CCSpriteBatchNode.js
  65. +8 −7 cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js
  66. +80 −62 cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js
  67. +1 −1 cocos2d/core/sprites/CCSpriteFrame.js
  68. +52 −35 cocos2d/core/sprites/CCSpriteFrameCache.js
  69. +19 −15 cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js
  70. +7 −6 cocos2d/core/support/CCPointExtension.js
  71. +3 −3 cocos2d/core/support/CCVertex.js
  72. +46 −9 cocos2d/core/textures/CCTexture2D.js
  73. +4 −4 cocos2d/core/textures/CCTextureAtlas.js
  74. +4 −4 cocos2d/core/textures/CCTextureCache.js
  75. +25 −17 cocos2d/core/textures/TexturesWebGL.js
  76. +4 −4 cocos2d/core/utils/BinaryLoader.js
  77. +1 −1 cocos2d/effects/CCGrabber.js
  78. +93 −13 cocos2d/effects/CCGrid.js
  79. +31 −21 cocos2d/kazmath/aabb.js
  80. +66 −27 cocos2d/kazmath/gl/mat4stack.js
  81. +133 −135 cocos2d/kazmath/gl/matrix.js
Sorry, we could not display the entire diff because it was too big.
View
1 .gitignore
@@ -7,3 +7,4 @@ node_modules
/tools/jsdoc_toolkit-2.4.0
/package
/tools/jsdoc_toolkit/jsdoc_toolkit-2.4.0
+/.project
View
45 AUTHORS.txt
@@ -12,11 +12,11 @@ Core Developers:
Ricardo Quesada
- Huabin LING (pandamicro)
+ Huabin LING (@pandamicro)
- Sijie Wang
+ Sijie Wang (@VisualSJ)
- Jialong Zhai
+ Jialong Zhai (@JoshuaAstray)
Contributors:
Name GithubID Main contribution
@@ -86,8 +86,9 @@ 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
@@ -169,13 +170,14 @@ Asano @LaercioAsano cc.Node bug fix
Bruno Assarisse @bassarisse cc.LabelBMFont bug fix
-Mykyta Usikov @musikov cc.ClippingNode 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
Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix
@@ -187,6 +189,7 @@ Xiaodong Liu @tianxing113 cc.Spawn.create 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
@@ -219,11 +222,41 @@ 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
+
+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`
+
+
+
Retired Core Developers:
Shengxiang Chen (Nero Chan)
Xingsen Ma
View
336 CCBoot.js
@@ -114,7 +114,7 @@ cc.extend = function(target) {
* @returns {boolean}
*/
cc.isFunction = function(obj) {
- return typeof obj == 'function';
+ return typeof obj === 'function';
};
/**
@@ -123,7 +123,7 @@ cc.isFunction = function(obj) {
* @returns {boolean}
*/
cc.isNumber = function(obj) {
- return typeof obj == 'number' || Object.prototype.toString.call(obj) == '[object Number]';
+ return typeof obj === 'number' || Object.prototype.toString.call(obj) === '[object Number]';
};
/**
@@ -132,7 +132,7 @@ cc.isNumber = function(obj) {
* @returns {boolean}
*/
cc.isString = function(obj) {
- return typeof obj == 'string' || Object.prototype.toString.call(obj) == '[object String]';
+ return typeof obj === 'string' || Object.prototype.toString.call(obj) === '[object String]';
};
/**
@@ -141,7 +141,8 @@ cc.isString = function(obj) {
* @returns {boolean}
*/
cc.isArray = function(obj) {
- return Object.prototype.toString.call(obj) == '[object Array]';
+ return Array.isArray(obj) ||
+ (typeof obj === 'object' && Object.prototype.toString.call(obj) === '[object Array]');
};
/**
@@ -150,7 +151,7 @@ cc.isArray = function(obj) {
* @returns {boolean}
*/
cc.isUndefined = function(obj) {
- return typeof obj == 'undefined';
+ return typeof obj === 'undefined';
};
/**
@@ -159,9 +160,7 @@ cc.isUndefined = function(obj) {
* @returns {boolean}
*/
cc.isObject = function(obj) {
- var type = typeof obj;
-
- return type == 'function' || (obj && type == 'object');
+ return typeof obj === "object" && Object.prototype.toString.call(obj) === '[object Object]';
};
/**
@@ -175,12 +174,12 @@ cc.isCrossOrigin = function (url) {
return false;
}
var startIndex = url.indexOf("://");
- if (startIndex == -1)
+ if (startIndex === -1)
return false;
var endIndex = url.indexOf("/", startIndex + 3);
- var urlOrigin = (endIndex == -1) ? url : url.substring(0, endIndex);
- return urlOrigin != location.origin;
+ var urlOrigin = (endIndex === -1) ? url : url.substring(0, endIndex);
+ return urlOrigin !== location.origin;
};
//+++++++++++++++++++++++++something about async begin+++++++++++++++++++++++++++++++
@@ -227,7 +226,7 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){
self._handleItem = function(){
var self = this;
- if(self._pool.length == 0 || self._workingSize >= self._limit)
+ 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();
@@ -249,7 +248,7 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){
var arr = Array.prototype.slice.call(arguments, 1);
self._results[this.index] = arr[0];
- if (self.finishedSize == self.size) {
+ if (self.finishedSize === self.size) {
if (self._onEnd)
self._onEnd.call(self._onEndTarget, null, self._results);
return;
@@ -261,7 +260,7 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){
self.flow = function(){
var self = this;
- if(self._pool.length == 0) {
+ if(self._pool.length === 0) {
if(self._onEnd)
self._onEnd.call(self._onEndTarget, null, []);
return;
@@ -319,7 +318,7 @@ cc.async = /** @lends cc.async# */{
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
+ if(tasks.length - 1 === index) lastResults = lastResults.concat(args);//while the last task
cb1.apply(null, arguments);
});
func.apply(target, args);
@@ -344,7 +343,7 @@ cc.async = /** @lends cc.async# */{
*/
map : function(tasks, iterator, callback, target){
var locIterator = iterator;
- if(typeof(iterator) == "object"){
+ if(typeof(iterator) === "object"){
callback = iterator.cb;
target = iterator.iteratorTarget;
locIterator = iterator.iterator;
@@ -389,7 +388,7 @@ cc.path = /** @lends cc.path# */{
var l = arguments.length;
var result = "";
for (var i = 0; i < l; i++) {
- result = (result + (result == "" ? "" : "/") + arguments[i]).replace(/(\/|\\\\)$/, "");
+ result = (result + (result === "" ? "" : "/") + arguments[i]).replace(/(\/|\\\\)$/, "");
}
return result;
},
@@ -442,7 +441,7 @@ cc.path = /** @lends cc.path# */{
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())
+ if (extname && pathStr.substring(pathStr.length - extname.length).toLowerCase() === extname.toLowerCase())
return baseName.substring(0, baseName.length - extname.length);
return baseName;
},
@@ -500,7 +499,7 @@ cc.path = /** @lends cc.path# */{
* @returns {string}
*/
changeBasename: function (pathStr, basename, isSameExt) {
- if (basename.indexOf(".") == 0) return this.changeExtname(pathStr, basename);
+ if (basename.indexOf(".") === 0) return this.changeExtname(pathStr, basename);
var index = pathStr.indexOf("?");
var tempStr = "";
var ext = isSameExt ? this.extname(pathStr) : "";
@@ -546,7 +545,7 @@ cc.loader = /** @lends cc.loader# */{
if (args.length === 1) {
results[1] = a0 instanceof Array ? a0 : [a0];
} else if (args.length === 2) {
- if (typeof a1 == "function") {
+ if (typeof a1 === "function") {
results[1] = a0 instanceof Array ? a0 : [a0];
results[2] = a1;
} else {
@@ -604,8 +603,15 @@ cc.loader = /** @lends cc.loader# */{
_createScript: function (jsPath, isAsync, cb) {
var d = document, self = this, s = cc.newElement('script');
s.async = isAsync;
- s.src = jsPath;
self._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;
+ }
cc._addEventListener(s, 'load', function () {
s.parentNode.removeChild(s);
this.removeEventListener('load', arguments.callee, false);
@@ -665,14 +671,14 @@ cc.loader = /** @lends cc.loader# */{
// IE-specific logic here
xhr.setRequestHeader("Accept-Charset", "utf-8");
xhr.onreadystatechange = function () {
- if(xhr.readyState == 4)
- xhr.status == 200 ? cb(null, xhr.responseText) : cb(errInfo);
+ if(xhr.readyState === 4)
+ xhr.status === 200 ? cb(null, xhr.responseText) : cb(errInfo);
};
} else {
if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8");
xhr.onload = function () {
- if(xhr.readyState == 4)
- xhr.status == 200 ? cb(null, xhr.responseText) : cb(errInfo);
+ if(xhr.readyState === 4)
+ xhr.status === 200 ? cb(null, xhr.responseText) : cb(errInfo);
};
}
xhr.send(null);
@@ -694,7 +700,7 @@ cc.loader = /** @lends cc.loader# */{
if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8");
}
xhr.send(null);
- if (!xhr.readyState == 4 || xhr.status != 200) {
+ if (!xhr.readyState === 4 || xhr.status !== 200) {
return null;
}
return xhr.responseText;
@@ -714,8 +720,8 @@ cc.loader = /** @lends cc.loader# */{
if (arrayBuffer) {
window.msg = arrayBuffer;
}
- if(xhr.readyState == 4)
- xhr.status == 200 ? cb(null, xhr.response) : cb("load " + url + " failed!");
+ if(xhr.readyState === 4)
+ xhr.status === 200 ? cb(null, xhr.response) : cb("load " + url + " failed!");
};
xhr.send(null);
@@ -760,7 +766,7 @@ cc.loader = /** @lends cc.loader# */{
isCrossOrigin: true
};
if (callback !== undefined)
- opt.isCrossOrigin = option.isCrossOrigin == null ? opt.isCrossOrigin : option.isCrossOrigin;
+ opt.isCrossOrigin = option.isCrossOrigin === null ? opt.isCrossOrigin : option.isCrossOrigin;
else if (option !== undefined)
callback = option;
@@ -771,7 +777,7 @@ cc.loader = /** @lends cc.loader# */{
}
img = new Image();
- if (opt.isCrossOrigin && location.origin != "file://")
+ if (opt.isCrossOrigin && location.origin !== "file://")
img.crossOrigin = "Anonymous";
var loadCallback = function () {
@@ -783,14 +789,16 @@ cc.loader = /** @lends cc.loader# */{
callback(null, img);
};
+ var self = this;
var errorCallback = function () {
this.removeEventListener('error', errorCallback, false);
- if(img.crossOrigin && img.crossOrigin.toLowerCase() == "anonymous"){
+ if(img.crossOrigin && img.crossOrigin.toLowerCase() === "anonymous"){
opt.isCrossOrigin = false;
+ self.release(url);
cc.loader.loadImg(url, opt, callback);
}else{
- typeof callback == "function" && callback("load image failed");
+ typeof callback === "function" && callback("load image failed");
}
};
@@ -832,6 +840,12 @@ cc.loader = /** @lends cc.loader# */{
}
var basePath = loader.getBasePath ? loader.getBasePath() : self.resPath;
var 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);
@@ -844,6 +858,7 @@ cc.loader = /** @lends cc.loader# */{
}
});
},
+ _noCacheRex: /\?/,
/**
* Get url with basePath.
@@ -883,20 +898,20 @@ cc.loader = /** @lends cc.loader# */{
load : function(resources, option, loadCallback){
var self = this;
var len = arguments.length;
- if(len == 0)
+ if(len === 0)
throw "arguments error!";
- if(len == 3){
- if(typeof option == "function"){
- if(typeof loadCallback == "function")
+ 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")
+ }else if(len === 2){
+ if(typeof option === "function")
option = {cb : option};
- }else if(len == 1){
+ }else if(len === 1){
option = {};
}
@@ -977,7 +992,7 @@ cc.loader = /** @lends cc.loader# */{
register: function (extNames, loader) {
if (!extNames || !loader) return;
var self = this;
- if (typeof extNames == "string")
+ if (typeof extNames === "string")
return this._register[extNames.trim().toLowerCase()] = loader;
for (var i = 0, li = extNames.length; i < li; i++) {
self._register["." + extNames[i].trim().toLowerCase()] = loader;
@@ -1032,15 +1047,15 @@ cc.formatStr = function(){
var str = args[0];
var needToFormat = true;
- if(typeof str == "object"){
+ 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"){
+ if(typeof arg === "number"){
result = str.match(/(%d)|(%s)/);
if(result){
str = str.replace(/(%d)|(%s)/, arg);
@@ -1306,32 +1321,32 @@ cc._initSys = function (config, CONFIG_KEY) {
/**
* @memberof cc.sys
- * @name OS_WINDOWS
+ * @name OS_IOS
* @constant
* @type {string}
*/
- sys.OS_WINDOWS = "Windows";
+ sys.OS_IOS = "iOS";
/**
* @memberof cc.sys
- * @name OS_IOS
+ * @name OS_ANDROID
* @constant
* @type {string}
*/
- sys.OS_IOS = "iOS";
+ sys.OS_ANDROID = "Android";
/**
* @memberof cc.sys
- * @name OS_OSX
+ * @name OS_WINDOWS
* @constant
* @type {string}
*/
- sys.OS_OSX = "OS X";
+ sys.OS_WINDOWS = "Windows";
/**
* @memberof cc.sys
- * @name OS_UNIX
+ * @name OS_MARMALADE
* @constant
* @type {string}
*/
- sys.OS_UNIX = "UNIX";
+ sys.OS_MARMALADE = "Marmalade";
/**
* @memberof cc.sys
* @name OS_LINUX
@@ -1341,11 +1356,39 @@ cc._initSys = function (config, CONFIG_KEY) {
sys.OS_LINUX = "Linux";
/**
* @memberof cc.sys
- * @name OS_ANDROID
+ * @name OS_BADA
* @constant
* @type {string}
*/
- sys.OS_ANDROID = "Android";
+ 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
@@ -1356,100 +1399,124 @@ cc._initSys = function (config, CONFIG_KEY) {
/**
* @memberof cc.sys
- * @name WINDOWS
+ * @name UNKNOWN
* @constant
* @default
* @type {Number}
*/
- sys.WINDOWS = 0;
+ sys.UNKNOWN = 0;
/**
* @memberof cc.sys
- * @name LINUX
+ * @name IOS
* @constant
* @default
* @type {Number}
*/
- sys.LINUX = 1;
+ sys.IOS = 1;
/**
* @memberof cc.sys
- * @name MACOS
+ * @name ANDROID
* @constant
* @default
* @type {Number}
*/
- sys.MACOS = 2;
+ sys.ANDROID = 2;
/**
* @memberof cc.sys
- * @name ANDROID
+ * @name WIN32
+ * @constant
+ * @default
+ * @type {Number}
+ */
+ sys.WIN32 = 3;
+ /**
+ * @memberof cc.sys
+ * @name MARMALADE
* @constant
* @default
* @type {Number}
*/
- sys.ANDROID = 3;
+ sys.MARMALADE = 4;
/**
* @memberof cc.sys
- * @name IPHONE
+ * @name LINUX
* @constant
* @default
* @type {Number}
*/
- sys.IPHONE = 4;
+ sys.LINUX = 5;
/**
* @memberof cc.sys
- * @name IPAD
+ * @name BADA
* @constant
* @default
* @type {Number}
*/
- sys.IPAD = 5;
+ sys.BADA = 6;
/**
* @memberof cc.sys
* @name BLACKBERRY
* @constant
* @default
* @type {Number}
*/
- sys.BLACKBERRY = 6;
+ sys.BLACKBERRY = 7;
+ /**
+ * @memberof cc.sys
+ * @name MACOS
+ * @constant
+ * @default
+ * @type {Number}
+ */
+ sys.MACOS = 8;
/**
* @memberof cc.sys
* @name NACL
* @constant
* @default
* @type {Number}
*/
- sys.NACL = 7;
+ sys.NACL = 9;
/**
* @memberof cc.sys
* @name EMSCRIPTEN
* @constant
* @default
* @type {Number}
*/
- sys.EMSCRIPTEN = 8;
+ sys.EMSCRIPTEN = 10;
/**
* @memberof cc.sys
* @name TIZEN
* @constant
* @default
* @type {Number}
*/
- sys.TIZEN = 9;
+ sys.TIZEN = 11;
/**
* @memberof cc.sys
- * @name WINRT
+ * @name QT5
* @constant
* @default
* @type {Number}
*/
- sys.WINRT = 10;
+ sys.QT5 = 12;
/**
* @memberof cc.sys
* @name WP8
* @constant
* @default
* @type {Number}
*/
- sys.WP8 = 11;
+ sys.WP8 = 13;
+ /**
+ * @memberof cc.sys
+ * @name WINRT
+ * @constant
+ * @default
+ * @type {Number}
+ */
+ sys.WINRT = 14;
/**
* @memberof cc.sys
* @name MOBILE_BROWSER
@@ -1496,13 +1563,6 @@ cc._initSys = function (config, CONFIG_KEY) {
*/
sys.isNative = false;
- var browserSupportWebGL = [sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_SAFARI];
- var osSupportWebGL = [sys.OS_IOS, sys.OS_WINDOWS, sys.OS_OSX, sys.OS_LINUX];
- var multipleAudioWhiteList = [
- sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_BAIDU_APP,
- sys.BROWSER_TYPE_SAFARI, sys.BROWSER_TYPE_UC, sys.BROWSER_TYPE_QQ, sys.BROWSER_TYPE_MOBILE_QQ, sys.BROWSER_TYPE_IE
- ];
-
var win = window, nav = win.navigator, doc = document, docEle = doc.documentElement;
var ua = nav.userAgent.toLowerCase();
@@ -1512,7 +1572,7 @@ cc._initSys = function (config, CONFIG_KEY) {
* @name isMobile
* @type {Boolean}
*/
- sys.isMobile = ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1;
+ sys.isMobile = ua.indexOf('mobile') !== -1 || ua.indexOf('android') !== -1;
/**
* Indicate the running platform
@@ -1539,12 +1599,14 @@ cc._initSys = function (config, CONFIG_KEY) {
|| ua.match(/chrome|safari/i);
if (browserTypes && browserTypes.length > 0) {
browserType = browserTypes[0];
- if (browserType == 'micromessenger') {
+ if (browserType === 'micromessenger') {
browserType = sys.BROWSER_TYPE_WECHAT;
} else if (browserType === "safari" && (ua.match(/android.*applewebkit/)))
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 === "trident") browserType = sys.BROWSER_TYPE_IE;
+ else if (browserType === "360 aphone") browserType = sys.BROWSER_TYPE_360;
+ }else if(ua.indexOf("iphone") && ua.indexOf("mobile")){
+ browserType = "safari";
}
/**
* Indicate the running browser type
@@ -1558,12 +1620,12 @@ cc._initSys = function (config, CONFIG_KEY) {
var iOS = ( ua.match(/(iPad|iPhone|iPod)/i) ? true : false );
var isAndroid = ua.match(/android/i) || nav.platform.match(/android/i) ? true : false;
var osName = sys.OS_UNKNOWN;
- if (nav.appVersion.indexOf("Win") != -1) osName = sys.OS_WINDOWS;
+ 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) osName = sys.OS_UNIX;
+ 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;
+ else if (nav.appVersion.indexOf("Linux") !== -1) osName = sys.OS_LINUX;
/**
* Indicate the running os name
@@ -1573,18 +1635,44 @@ cc._initSys = function (config, CONFIG_KEY) {
*/
sys.os = osName;
+ var multipleAudioWhiteList = [
+ sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_BAIDU_APP,
+ sys.BROWSER_TYPE_SAFARI, sys.BROWSER_TYPE_UC, sys.BROWSER_TYPE_QQ, sys.BROWSER_TYPE_MOBILE_QQ, sys.BROWSER_TYPE_IE
+ ];
+
sys._supportMultipleAudio = multipleAudioWhiteList.indexOf(sys.browserType) > -1;
//++++++++++++++++++something about cc._renderTYpe and cc._supportRender begin++++++++++++++++++++++++++++
- var userRenderMode = parseInt(config[CONFIG_KEY.renderMode]);
- var renderType = cc._RENDER_TYPE_WEBGL;
- var tempCanvas = cc.newElement("Canvas");
- cc._supportRender = true;
- var notSupportGL = !window.WebGLRenderingContext || browserSupportWebGL.indexOf(sys.browserType) == -1 || osSupportWebGL.indexOf(sys.os) == -1;
- if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin == "file://")) {
- renderType = cc._RENDER_TYPE_CANVAS;
- }
+
+ (function(sys, config){
+ var userRenderMode = config[CONFIG_KEY.renderMode] - 0;
+ if(isNaN(userRenderMode) || userRenderMode > 2 || userRenderMode < 0)
+ userRenderMode = 0;
+ var shieldOs = [sys.OS_ANDROID];
+ var shieldBrowser = [];
+ var tmpCanvas = cc.newElement("canvas");
+ cc._renderType = cc._RENDER_TYPE_CANVAS;
+ cc._supportRender = false;
+
+ var supportWebGL = win.WebGLRenderingContext;
+
+ if(userRenderMode === 2 || (userRenderMode === 0 && supportWebGL && shieldOs.indexOf(sys.os) === -1 && shieldBrowser.indexOf(sys.browserType) === -1))
+ try{
+ var context = cc.create3DContext(tmpCanvas, {'stencil': true, 'preserveDrawingBuffer': true });
+ if(context){
+ cc._renderType = cc._RENDER_TYPE_WEBGL;
+ cc._supportRender = true;
+ }
+ }catch(e){}
+
+ if(userRenderMode === 1 || (userRenderMode === 0 && cc._supportRender === false))
+ try {
+ tmpCanvas.getContext("2d");
+ cc._renderType = cc._RENDER_TYPE_CANVAS;
+ cc._supportRender = true;
+ } catch (e) {}
+ })(sys, config);
sys._canUseCanvasNewBlendModes = function(){
var canvas = document.createElement('canvas');
@@ -1610,22 +1698,6 @@ cc._initSys = function (config, CONFIG_KEY) {
//Whether or not the Canvas BlendModes are supported.
sys._supportCanvasNewBlendModes = sys._canUseCanvasNewBlendModes();
- if (renderType == cc._RENDER_TYPE_WEBGL) {
- if (!win.WebGLRenderingContext
- || !cc.create3DContext(tempCanvas, {'stencil': true, 'preserveDrawingBuffer': true })) {
- if (userRenderMode == 0) renderType = cc._RENDER_TYPE_CANVAS;
- else cc._supportRender = false;
- }
- }
-
- if (renderType == cc._RENDER_TYPE_CANVAS) {
- try {
- tempCanvas.getContext("2d");
- } catch (e) {
- cc._supportRender = false;
- }
- }
- cc._renderType = renderType;
//++++++++++++++++++something about cc._renderType and cc._supportRender end++++++++++++++++++++++++++++++
// check if browser supports Web Audio
@@ -1656,7 +1728,7 @@ cc._initSys = function (config, CONFIG_KEY) {
}
var capabilities = sys.capabilities = {"canvas": true};
- if (cc._renderType == cc._RENDER_TYPE_WEBGL)
+ if (cc._renderType === cc._RENDER_TYPE_WEBGL)
capabilities["opengl"] = true;
if (docEle['ontouchstart'] !== undefined || doc['ontouchstart'] !== undefined || nav.msPointerEnabled)
capabilities["touches"] = true;
@@ -1709,6 +1781,21 @@ cc._initSys = function (config, CONFIG_KEY) {
};
/**
+ * 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
@@ -1725,6 +1812,16 @@ cc._initSys = function (config, CONFIG_KEY) {
str += "platform : " + self.platform + "\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);
+ }
};
//+++++++++++++++++++++++++something about sys end+++++++++++++++++++++++++++++
@@ -1818,7 +1915,7 @@ cc._setup = function (el, width, height) {
cc.game._setAnimFrame();
- if (element.tagName == "CANVAS") {
+ if (element.tagName === "CANVAS") {
width = width || element.width;
height = height || element.height;
@@ -1829,7 +1926,7 @@ cc._setup = function (el, width, height) {
localCanvas.appendTo(localContainer);
localContainer.setAttribute('id', 'Cocos2dGameContainer');
} else {//we must make a new canvas and place into this element
- if (element.tagName != "DIV") {
+ if (element.tagName !== "DIV") {
cc.log("Warning: target element is not a DIV or CANVAS");
}
width = width || element.clientWidth;
@@ -1853,12 +1950,13 @@ cc._setup = function (el, width, height) {
localConStyle.overflow = 'hidden';
localContainer.top = '100%';
- if (cc._renderType == cc._RENDER_TYPE_WEBGL)
+ if (cc._renderType === cc._RENDER_TYPE_WEBGL)
cc._renderContext = cc.webglContext = cc.create3DContext(localCanvas, {
'stencil': true,
'preserveDrawingBuffer': true,
'antialias': !cc.sys.isMobile,
- 'alpha': false});
+ 'alpha': false
+ });
if (cc._renderContext) {
win.gl = cc._renderContext; // global variable declared in CCMacro.js
cc._drawingUtil = new cc.DrawingPrimitiveWebGL(cc._renderContext);
@@ -2015,7 +2113,7 @@ cc.game = /** @lends cc.game# */{
_setAnimFrame: function () {
this._lastTime = new Date();
this._frameTime = 1000 / cc.game.config[cc.game.CONFIG_KEY.frameRate];
- if((cc.sys.os === cc.sys.OS_IOS && cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT) || cc.game.config[cc.game.CONFIG_KEY.frameRate] != 60) {
+ if((cc.sys.os === cc.sys.OS_IOS && cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT) || cc.game.config[cc.game.CONFIG_KEY.frameRate] !== 60) {
window.requestAnimFrame = this._stTime;
window.cancelAnimationFrame = this._ctTime;
}
@@ -2136,7 +2234,7 @@ cc.game = /** @lends cc.game# */{
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;}
+ if(_t === '' || _t){break;}
}
var _src, txt, _resPath;
if(i < cocos_script.length){
@@ -2179,7 +2277,7 @@ cc.game = /** @lends cc.game# */{
if (!extname) {
var arr = this._getJsListOfModule(moduleMap, item, dir);
if (arr) jsList = jsList.concat(arr);
- } else if (extname.toLowerCase() == ".js") jsList.push(ccPath.join(dir, item));
+ } else if (extname.toLowerCase() === ".js") jsList.push(ccPath.join(dir, item));
jsAddedCache[item] = 1;
}
return jsList;
@@ -2212,7 +2310,7 @@ cc.game = /** @lends cc.game# */{
var modules = config["modules"] || [];
var moduleMap = modulesJson["module"];
var newJsList = [];
- if (cc._renderType == cc._RENDER_TYPE_WEBGL) modules.splice(0, 0, "shaders");
+ if (cc._renderType === cc._RENDER_TYPE_WEBGL) modules.splice(0, 0, "shaders");
else if (modules.indexOf("core") < 0) modules.splice(0, 0, "core");
for (var i = 0, li = modules.length; i < li; i++) {
var arr = self._getJsListOfModule(moduleMap, modules[i], engineDir);
View
10 CCDebugger.js
@@ -282,7 +282,7 @@ cc._formatString = function (arg) {
*/
cc._initDebugSetting = function (mode) {
var ccGame = cc.game;
- if(mode == ccGame.DEBUG_MODE_NONE)
+ if(mode === ccGame.DEBUG_MODE_NONE)
return;
var locLog;
@@ -299,12 +299,12 @@ cc._initDebugSetting = function (mode) {
locLog("Assert: " + msg);
}
};
- if(mode != ccGame.DEBUG_MODE_ERROR_FOR_WEB_PAGE){
+ 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){
+ if(mode === ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE){
cc.log = function(){
locLog(cc.formatStr.apply(cc, arguments));
};
@@ -322,11 +322,11 @@ cc._initDebugSetting = function (mode) {
throw msg;
}
};
- if(mode != ccGame.DEBUG_MODE_ERROR)
+ if(mode !== ccGame.DEBUG_MODE_ERROR)
cc.warn = function(){
return console.warn.apply(console, arguments);
};
- if(mode == ccGame.DEBUG_MODE_INFO)
+ if(mode === ccGame.DEBUG_MODE_INFO)
cc.log = function(){
return console.log.apply(console, arguments);
};
View
200 CHANGELOG.txt
@@ -1,5 +1,205 @@
ChangeLog:
+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 movment 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.
View
13 README.mdown
@@ -3,7 +3,7 @@ Cocos2d-html5
[Cocos2d-html5][1] is a cross-platform 2D game engine written in Javascript, based on [Cocos2d-X][2] and licensed under MIT.
It incorporates the same high level api as “Cocos2d JS-binding engine” and compatible with Cocos2d-X.
-It currently supports canvas and will support WebGL in the future.
+It currently supports canvas and WebGL renderer.
Cross Platform
-------------
@@ -16,7 +16,15 @@ Documentation
* Website: [www.cocos2d-x.org][3]
* API References: [http://www.cocos2d-x.org/wiki/Reference] [4]
-Running the tests
+
+Installing from [bower][8] (version >=3.4)
+------------------
+
+```shell
+$ bower install cocos2d-html5
+```
+
+Running the tests (version <3)
------------------
```shell
@@ -41,3 +49,4 @@ Contact us
[5]: http://forum.cocos2d-x.org "http://forum.cocos2d-x.org"
[6]: http://www.twitter.com/cocos2dhtml5 "http://www.twitter.com/cocos2dhtml5"
[7]: http://t.sina.com.cn/cocos2dhtml5 "http://t.sina.com.cn/cocos2dhtml5"
+[8]: http://bower.io "http://bower.io"
View
37 bower.json
@@ -0,0 +1,37 @@
+{
+ "name": "cocos2d-html5",
+ "version": "3.4",
+ "homepage": "http://www.cocos2d-x.org",
+ "authors": [
+ "AUTHORS.txt"
+ ],
+ "description": "Cocos2d-html5 is a cross-platform 2D game engine written in Javascript, based on Cocos2d-X and licensed under MIT. It incorporates the same high level api as “Cocos2d JS-binding engine” and compatible with Cocos2d-X. It currently supports canvas and WebGL renderering.",
+ "main": "README.mdown",
+ "keywords": [
+ "cocos2d-x",
+ "cocos2d",
+ "game",
+ "engine",
+ "opengl",
+ "cross",
+ "multi",
+ "platform",
+ "iphone",
+ "ipad",
+ "android",
+ "windows",
+ "metro",
+ "bada",
+ "marmalade",
+ "playbook"
+ ],
+ "license": "MIT",
+ "private": false,
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ]
+}
View
6 cocos2d/actions/CCAction.js
@@ -255,7 +255,7 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{
* @return {Number}
*/
getDuration:function () {
- return this._duration * (this._times || 1);
+ return this._duration * (this._timesForRepeat || 1);
},
/**
@@ -422,7 +422,7 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{
* @param {cc.ActionInterval} action
*/
setInnerAction:function (action) {
- if (this._innerAction != action) {
+ if (this._innerAction !== action) {
this._innerAction = action;
}
},
@@ -607,7 +607,7 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
_this.topBoundary = _this.bottomBoundary = (_this.topBoundary + _this.bottomBoundary) / 2;
}
- if ((_this.topBoundary == _this.bottomBoundary) && (_this.leftBoundary == _this.rightBoundary))
+ if ((_this.topBoundary === _this.bottomBoundary) && (_this.leftBoundary === _this.rightBoundary))
_this._boundaryFullyCovered = true;
}
return true;
View
6 cocos2d/actions/CCActionCatmullRom.js
@@ -174,7 +174,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
* @return {Boolean}
*/
initWithDuration:function (duration, points, tension) {
- if(!points || points.length == 0)
+ if(!points || points.length === 0)
throw "Invalid configuration. It must at least have one control point";
if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
@@ -222,7 +222,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
// p..p..p..p..p..p..p
// 1..2..3..4..5..6..7
// want p to be 1, 2, 3, 4, 5, 6
- if (dt == 1) {
+ if (dt === 1) {
p = ps.length - 1;
lt = 1;
} else {
@@ -242,7 +242,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
var tempX, tempY;
tempX = this.target.getPositionX() - this._previousPosition.x;
tempY = this.target.getPositionY() - this._previousPosition.y;
- if (tempX != 0 || tempY != 0) {
+ if (tempX !== 0 || tempY !== 0) {
var locAccDiff = this._accumulatedDiff;
tempX = locAccDiff.x + tempX;
tempY = locAccDiff.y + tempY;
View
14 cocos2d/actions/CCActionEase.js
@@ -651,7 +651,7 @@ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# *
* @param {Number} dt
*/
update:function (dt) {
- this._inner.update(dt == 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1));
+ this._inner.update(dt === 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1));
},
/**
@@ -696,7 +696,7 @@ cc.EaseExponentialOut.create = function (action) {
cc._easeExponentialOutObj = {
easing: function(dt){
- return dt == 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1);
+ return dt === 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1);
},
reverse: function(){
return cc._easeExponentialInObj;
@@ -740,7 +740,7 @@ cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOu
* @param {Number} dt
*/
update:function (dt) {
- if( dt != 1 && dt !== 0) {
+ if( dt !== 1 && dt !== 0) {
dt *= 2;
if (dt < 1)
dt = 0.5 * Math.pow(2, 10 * (dt - 1));
@@ -976,7 +976,7 @@ cc.EaseSineOut.create = function (action) {
cc._easeSineOutObj = {
easing: function(dt){
- return (dt===0 || dt==1) ? dt : Math.sin(dt * Math.PI / 2);
+ return (dt===0 || dt===1) ? dt : Math.sin(dt * Math.PI / 2);
},
reverse: function(){
return cc._easeSineInObj;
@@ -1313,7 +1313,7 @@ cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{
*/
update:function (dt) {
var newT = 0;
- if (dt === 0 || dt == 1) {
+ if (dt === 0 || dt === 1) {
newT = dt;
} else {
var s = this._period / 4;
@@ -1423,7 +1423,7 @@ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{
update:function (dt) {
var newT = 0;
var locPeriod = this._period;
- if (dt === 0 || dt == 1) {
+ if (dt === 0 || dt === 1) {
newT = dt;
} else {
dt = dt * 2;
@@ -1891,7 +1891,7 @@ cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{
*/
update:function (dt) {
var overshoot = 1.70158;
- dt = dt===0 || dt==1 ? dt : dt * dt * ((overshoot + 1) * dt - overshoot);
+ dt = dt===0 || dt===1 ? dt : dt * dt * ((overshoot + 1) * dt - overshoot);
this._inner.update(dt);
},
View
2 cocos2d/actions/CCActionInstant.js
@@ -701,7 +701,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
* @param {object} sel
*/
setTargetCallback:function (sel) {
- if (sel != this._selectorTarget) {
+ if (sel !== this._selectorTarget) {
if (this._selectorTarget)
this._selectorTarget = null;
this._selectorTarget = sel;
View
58 cocos2d/actions/CCActionInterval.js
@@ -47,7 +47,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
_elapsed:0,
_firstTick:false,
_easeList: null,
- _times:1,
+ _timesForRepeat:1,
_repeatForever: false,
_repeatMethod: false,//Compatible with repeat class, Discard after can be deleted
_speed: 1,
@@ -59,7 +59,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
*/
ctor:function (d) {
this._speed = 1;
- this._times = 1;
+ this._timesForRepeat = 1;
this._repeatForever = false;
this.MAX_VALUE = 2;
this._repeatMethod = false;//Compatible with repeat class, Discard after can be deleted
@@ -107,7 +107,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
_cloneDecoration: function(action){
action._repeatForever = this._repeatForever;
action._speed = this._speed;
- action._times = this._times;
+ action._timesForRepeat = this._timesForRepeat;
action._easeList = this._easeList;
action._speedMethod = this._speedMethod;
action._repeatMethod = this._repeatMethod;
@@ -180,9 +180,9 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
this.update(t > 0 ? t : 0);
//Compatible with repeat class, Discard after can be deleted (this._repeatMethod)
- if(this._repeatMethod && this._times > 1 && this.isDone()){
+ if(this._repeatMethod && this._timesForRepeat > 1 && this.isDone()){
if(!this._repeatForever){
- this._times--;
+ this._timesForRepeat--;
}
//var diff = locInnerAction.getElapsed() - locInnerAction._duration;
this.startWithTarget(this.target);
@@ -286,7 +286,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
return this;
}
this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted
- this._times *= times;
+ this._timesForRepeat *= times;
return this;
},
@@ -297,7 +297,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
*/
repeatForever: function(){
this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted
- this._times = this.MAX_VALUE;
+ this._timesForRepeat = this.MAX_VALUE;
this._repeatForever = true;
return this;
}
@@ -466,7 +466,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{
if (locLast !== found)
actionFound.startWithTarget(this.target);
- new_t = new_t * actionFound._times;
+ new_t = new_t * actionFound._timesForRepeat;
actionFound.update(new_t > 1 ? new_t % 1 : new_t);
this._last = found;
},
@@ -501,12 +501,25 @@ cc.sequence = function (/*Multiple Arguments*/tempArray) {
if ((paramArray.length > 0) && (paramArray[paramArray.length - 1] == null))
cc.log("parameters should not be ending with null in Javascript");
- var prev = paramArray[0];
- for (var i = 1; i < paramArray.length; i++) {
- if (paramArray[i])
- prev = cc.Sequence._actionOneTwo(prev, paramArray[i]);
+ var result, current, i, repeat;
+ while(paramArray && paramArray.length > 0){
+ current = Array.prototype.shift.call(paramArray);
+ repeat = current._timesForRepeat || 1;
+ current._repeatMethod = false;
+ current._timesForRepeat = 1;
+
+ i = 0;
+ if(!result){
+ result = current;
+ i = 1;
+ }
+
+ for(i; i<repeat; i++){
+ result = cc.Sequence._actionOneTwo(result, current);
+ }
}
- return prev;
+
+ return result;
};
/**
@@ -656,7 +669,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{
* @return {Boolean}
*/
isDone:function () {
- return this._total == this._times;
+ return this._total === this._times;
},
/**
@@ -675,7 +688,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{
* @param {cc.FiniteTimeAction} action
*/
setInnerAction:function (action) {
- if (this._innerAction != action) {
+ if (this._innerAction !== action) {
this._innerAction = action;
}
},
@@ -813,7 +826,7 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{
* @param {cc.ActionInterval} action
*/
setInnerAction:function (action) {
- if (this._innerAction != action) {
+ if (this._innerAction !== action) {
this._innerAction = action;
}
},
@@ -2641,7 +2654,6 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{
time = this._computeEaseTime(time);
var fromOpacity = this._fromOpacity !== undefined ? this._fromOpacity : 255;
this.target.opacity = fromOpacity + (this._toOpacity - fromOpacity) * time;
-
},
/**
@@ -2693,7 +2705,9 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{
*/
ctor:function (duration) {
cc.FadeTo.prototype.ctor.call(this);
- duration && this.initWithDuration(duration, 255);
+ if (duration == null)
+ duration = 0;
+ this.initWithDuration(duration, 255);
},
/**
@@ -2767,7 +2781,9 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{
*/
ctor:function (duration) {
cc.FadeTo.prototype.ctor.call(this);
- duration && this.initWithDuration(duration, 0);
+ if (duration == null)
+ duration = 0;
+ this.initWithDuration(duration, 0);
},
/**
@@ -3150,7 +3166,7 @@ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{
initWithAction:function (action) {
if(!action)
throw "cc.ReverseTime.initWithAction(): action must be non null";
- if(action == this._other)
+ if(action === this._other)
throw "cc.ReverseTime.initWithAction(): the action was already passed in.";
if (cc.ActionInterval.prototype.initWithDuration.call(this, action._duration)) {
@@ -3511,7 +3527,7 @@ cc.TargetedAction = cc.ActionInterval.extend(/** @lends cc.TargetedAction# */{
* @param {cc.Node} forcedTarget
*/
setForcedTarget:function (forcedTarget) {
- if (this._forcedTarget != forcedTarget)
+ if (this._forcedTarget !== forcedTarget)
this._forcedTarget = forcedTarget;
}
});
View
55 cocos2d/actions3d/CCActionGrid.js
@@ -33,6 +33,7 @@
*/
cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{
_gridSize:null,
+ _gridNodeTarget:null,
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
@@ -47,6 +48,8 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{
gridSize && this.initWithDuration(duration, gridSize);
},
+ _cacheTargetAsGridNode: function(){},
+
/**
* to copy object with deep copy.
* returns a clone of action.
@@ -73,7 +76,7 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{
var targetGrid = t.grid;
if (targetGrid && targetGrid.getReuseGrid() > 0) {
var locGridSize = targetGrid.getGridSize();
- if (targetGrid.isActive() && (locGridSize.width == this._gridSize.width) && (locGridSize.height == this._gridSize.height))
+ if (targetGrid.isActive() && (locGridSize.width === this._gridSize.width) && (locGridSize.height === this._gridSize.height))
targetGrid.reuse();
} else {
if (targetGrid && targetGrid.isActive())
@@ -155,20 +158,40 @@ cc.Grid3DAction = cc.GridAction.extend(/** @lends cc.Grid3DAction# */{
},
/**
- * returns the vertex than belongs to certain position in the grid
+ * returns the vertex than belongs to certain position in the grid. <br/>
+ * It will be deprecated in future, please use getVertex instead.
* @param {cc.Point} position
* @return {cc.Vertex3F}
*/
vertex:function (position) {
- return this.target.grid.vertex(position);
+ return this.getVertex(position);
},
/**
- * returns the non-transformed vertex than belongs to certain position in the grid
+ * returns the vertex than belongs to certain position in the grid
+ * @param {cc.Point} position
+ * @return {cc.Vertex3F}
+ */
+ getVertex: function(position){
+ return this.target.grid.getVertex(position);
+ },
+
+ /**
+ * returns the non-transformed vertex than belongs to certain position in the grid <br/>
+ * It will be deprecated in future, please use getVertex instead.
* @param {cc.Point} position
* @return {cc.Vertex3F}
*/
originalVertex:function (position) {
+ return this.getOriginalVertex(position);
+ },
+
+ /**
+ * returns the non-transformed vertex than belongs to certain position in the grid
+ * @param {cc.Point} position
+ * @return {cc.Vertex3F}
+ */
+ getOriginalVertex:function (position) {
return this.target.grid.originalVertex(position);
},
@@ -211,20 +234,40 @@ cc.Grid3DAction.create = cc.grid3DAction;
cc.TiledGrid3DAction = cc.GridAction.extend(/** @lends cc.TiledGrid3DAction# */{
/**
- * returns the tile that belongs to a certain position of the grid
+ * returns the tile that belongs to a certain position of the grid <br/>
+ * It will be deprecated in future, please use getTile instead.
* @param {cc.Point} position
* @return {cc.Quad3}
*/
tile:function (position) {
+ return this.getTile(position);
+ },
+
+ /**
+ * returns the tile that belongs to a certain position of the grid
+ * @param {cc.Point} position
+ * @return {cc.Quad3}
+ */
+ getTile:function (position) {
return this.target.grid.tile(position);
},
/**
- * returns the non-transformed tile that belongs to a certain position of the grid
+ * returns the non-transformed tile that belongs to a certain position of the grid <br/>
+ * It will be deprecated in future, please use getOriginalTile instead.
* @param {cc.Point} position
* @return {cc.Quad3}
*/
originalTile:function (position) {
+ return this.getOriginalTile(position);
+ },
+
+ /**
+ * returns the non-transformed tile that belongs to a certain position of the grid
+ * @param {cc.Point} position
+ * @return {cc.Quad3}
+ */
+ getOriginalTile:function (position) {
return this.target.grid.originalTile(position);
},
View
4 cocos2d/actions3d/CCActionGrid3D.js
@@ -184,7 +184,7 @@ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{
* @return {Boolean}
*/
initWithSize:function (gridSize, duration) {
- if (gridSize.width != 1 || gridSize.height != 1) {
+ if (gridSize.width !== 1 || gridSize.height !== 1) {
// Grid size must be (1,1)
cc.log("Grid size must be (1,1)");
return false;
@@ -516,7 +516,7 @@ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{
if (r < locRadius) {
r = locRadius - r;
pre_log = r / locRadius;
- if (pre_log == 0)
+ if (pre_log === 0)
pre_log = 0.001;
l = Math.log(pre_log) * locLensEffect;
View
14 cocos2d/actions3d/CCActionPageTurn3D.js
@@ -36,6 +36,18 @@
* @extends cc.Grid3DAction
*/
cc.PageTurn3D = cc.Grid3DAction.extend(/** @lends cc.PageTurn3D# */{
+ getGrid: function(){
+ var result = new cc.Grid3D(this._gridSize);
+ result.setNeedDepthTestForBlit(true);
+ return result;
+ },
+
+ clone: function(){
+ var ret = new cc.PageTurn3D();
+ ret.initWithDuration(this._duration, this._gridSize);
+ return ret;
+ },
+
/**
* Update each tick <br/>
* Time is the percentage of the way through the duration
@@ -58,7 +70,7 @@ cc.PageTurn3D = cc.Grid3DAction.extend(/** @lends cc.PageTurn3D# */{
locVer.x = i;
locVer.y = j;
// Get original vertex
- var p = this.originalVertex(locVer);
+ var p = this.getOriginalVertex(locVer);
var R = Math.sqrt((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
var r = R * sinTheta;
View
16 cocos2d/actions3d/CCActionTiledGrid.js
@@ -457,7 +457,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */
testFunc:function (pos, time) {
var locX = this._gridSize.width * time;
var locY = this._gridSize.height * time;
- if ((locX + locY) == 0.0)
+ if ((locX + locY) === 0.0)
return 1.0;
return Math.pow((pos.width + pos.height) / (locX + locY), 6);
},
@@ -516,7 +516,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */
locSize.width = i;
locSize.height = j;
distance = this.testFunc(locSize, dt);
- if (distance == 0)
+ if (distance === 0)
this.turnOffTile(locPos);
else if (distance < 1)
this.transformTile(locPos, distance);
@@ -566,7 +566,7 @@ cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutBLTiles# */{
testFunc:function (pos, time) {
var locX = this._gridSize.width * (1.0 - time);
var locY = this._gridSize.height * (1.0 - time);
- if ((pos.width + pos.height) == 0)
+ if ((pos.width + pos.height) === 0)
return 1.0;
return Math.pow((locX + locY) / (pos.width + pos.height), 6);
@@ -606,7 +606,7 @@ cc.FadeOutBLTiles.create = cc.fadeOutBLTiles;
cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutUpTiles# */{
testFunc:function (pos, time) {
var locY = this._gridSize.height * time;
- if (locY == 0.0)
+ if (locY === 0.0)
return 1.0;
return Math.pow(pos.height / locY, 6);
},