diff --git a/CCBoot.js b/CCBoot.js
index eb825ffc1f..edd15e71e6 100644
--- a/CCBoot.js
+++ b/CCBoot.js
@@ -52,32 +52,19 @@ _p.ctor;
_p = null;
/**
- * Device oriented vertically, home button on the bottom
- * @constant
- * @type {Number}
+ * The current version of Cocos2d-JS being used.
+ * Please DO NOT remove this String, it is an important flag for bug tracking.
+ * If you post a bug to forum, please attach this flag.
+ * @type {String}
+ * @name cc.ENGINE_VERSION
*/
-cc.ORIENTATION_PORTRAIT = 0;
-
-/**
- * Device oriented vertically, home button on the top
- * @constant
- * @type {Number}
- */
-cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN = 1;
-
-/**
- * Device oriented horizontally, home button on the right
- * @constant
- * @type {Number}
- */
-cc.ORIENTATION_LANDSCAPE_LEFT = 2;
-
-/**
- * Device oriented horizontally, home button on the left
- * @constant
- * @type {Number}
- */
-cc.ORIENTATION_LANDSCAPE_RIGHT = 3;
+var engineVersion;
+if (CC_EDITOR) {
+ engineVersion = 'Cocos Creator v' + Editor.remote.versions.CocosCreator;
+} else {
+ engineVersion = 'Cocos Creator';
+}
+window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
/**
* drawing primitive of game engine
@@ -107,90 +94,6 @@ cc._gameDiv = null;
cc.isEditor = typeof Editor !== 'undefined';
-/**
- * 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;
- }
- }
-};
-
-/**
- * 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;
-};
-
-/**
- * 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;
-};
-
require('../cocos2d/core/utils');
require('../cocos2d/core/platform/CCSys');
require('../cocos2d/core/load-pipeline/CCLoader');
@@ -306,7 +209,7 @@ cc.initEngine = function (config, cb) {
_engineLoadedCallback = function () {
previousCallback && previousCallback();
cb && cb();
- }
+ };
return;
}
@@ -326,7 +229,7 @@ cc.initEngine = function (config, cb) {
document.body ? _load(config) : window.addEventListener('load', _windowLoaded, false);
_engineInitCalled = true;
-}
+};
})();
//+++++++++++++++++++++++++Engine initialization function end+++++++++++++++++++++++++++++
diff --git a/CCDebugger.js b/CCDebugger.js
index a9015122eb..0c37403e0a 100644
--- a/CCDebugger.js
+++ b/CCDebugger.js
@@ -35,7 +35,7 @@ cc._LogInfos = {
},
configuration: {
- dumpInfo: "cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)",
+ dumpInfo: "cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from CCMacro.js)",
loadConfigFile: "Expected 'data' dict, but not found. Config file: %s",
loadConfigFile_2: "Please load the resource first : %s",
},
@@ -125,8 +125,6 @@ cc._LogInfos = {
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",
spriteFrameAnimationCache: {
@@ -246,7 +244,6 @@ cc._LogInfos = {
},
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",
@@ -315,7 +312,7 @@ cc._logToWebPage = function (msg) {
};
//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) {
+function _formatString (arg) {
if (cc.js.isObject(arg)) {
try {
return JSON.stringify(arg);
@@ -386,24 +383,24 @@ cc._initDebugSetting = function (mode) {
//log to web page
locLog = cc._logToWebPage.bind(cc);
cc.error = function(){
- locLog("ERROR : " + cc.formatStr.apply(cc, arguments));
+ locLog("ERROR : " + cc.js.formatStr.apply(cc, arguments));
};
cc.assert = function(cond, msg) {
'use strict';
if (!cond && msg) {
for (var i = 2; i < arguments.length; i++)
- msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i]));
+ msg = msg.replace(/(%s)|(%d)/, _formatString(arguments[i]));
locLog("Assert: " + msg);
}
};
if(mode !== cc.DebugMode.ERROR_FOR_WEB_PAGE){
cc.warn = function(){
- locLog("WARN : " + cc.formatStr.apply(cc, arguments));
+ locLog("WARN : " + cc.js.formatStr.apply(cc, arguments));
};
}
if(mode === cc.DebugMode.INFO_FOR_WEB_PAGE){
cc.log = cc.info = function(){
- locLog(cc.formatStr.apply(cc, arguments));
+ locLog(cc.js.formatStr.apply(cc, arguments));
};
}
} else if(console && console.log.apply){//console is null when user doesn't open dev tool on IE9
@@ -436,7 +433,7 @@ cc._initDebugSetting = function (mode) {
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]));
+ msg = msg.replace(/(%s)|(%d)/, _formatString(arguments[i]));
throw new Error(msg);
}
};
diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js
index ffc3fe5d5a..90b8a432c0 100644
--- a/cocos2d/actions/CCActionCamera.js
+++ b/cocos2d/actions/CCActionCamera.js
@@ -193,9 +193,9 @@ cc.OrbitCamera = cc.ActionCamera.extend({
var r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
var s = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
if (s === 0.0)
- s = cc.FLT_EPSILON;
+ s = cc.Macro.FLT_EPSILON;
if (r === 0.0)
- r = cc.FLT_EPSILON;
+ r = cc.Macro.FLT_EPSILON;
zenith = Math.acos(z / r);
if (x < 0)
diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js
index 36c7b2b695..b85de71125 100644
--- a/cocos2d/actions/CCActionCatmullRom.js
+++ b/cocos2d/actions/CCActionCatmullRom.js
@@ -216,7 +216,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
cc.getControlPointAt(ps, p + 2),
this._tension, lt);
- if (cc.ENABLE_STACKABLE_ACTIONS) {
+ if (cc.Macro.ENABLE_STACKABLE_ACTIONS) {
var tempX, tempY;
tempX = this.target.getPositionX() - this._previousPosition.x;
tempY = this.target.getPositionY() - this._previousPosition.y;
diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js
index 00d3553358..11b0b7822c 100644
--- a/cocos2d/actions/CCActionInterval.js
+++ b/cocos2d/actions/CCActionInterval.js
@@ -1093,7 +1093,7 @@ cc.MoveBy = cc.ActionInterval.extend({
var x = this._positionDelta.x * dt;
var y = this._positionDelta.y * dt;
var locStartPosition = this._startPosition;
- if (cc.ENABLE_STACKABLE_ACTIONS) {
+ if (cc.Macro.ENABLE_STACKABLE_ACTIONS) {
var targetX = this.target.getPositionX();
var targetY = this.target.getPositionY();
var locPreviousPosition = this._previousPosition;
@@ -1460,7 +1460,7 @@ cc.JumpBy = cc.ActionInterval.extend({
var x = this._delta.x * dt;
var locStartPosition = this._startPosition;
- if (cc.ENABLE_STACKABLE_ACTIONS) {
+ if (cc.Macro.ENABLE_STACKABLE_ACTIONS) {
var targetX = this.target.getPositionX();
var targetY = this.target.getPositionY();
var locPreviousPosition = this._previousPosition;
@@ -1680,7 +1680,7 @@ cc.BezierBy = cc.ActionInterval.extend({
var y = cc.bezierAt(ya, yb, yc, yd, dt);
var locStartPosition = this._startPosition;
- if (cc.ENABLE_STACKABLE_ACTIONS) {
+ if (cc.Macro.ENABLE_STACKABLE_ACTIONS) {
var targetX = this.target.getPositionX();
var targetY = this.target.getPositionY();
var locPreviousPosition = this._previousPosition;
diff --git a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js
index 2fb7d1f6d4..c4dd0bdeb9 100644
--- a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js
+++ b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js
@@ -206,8 +206,8 @@
gl.stencilOp(!node.inverted ? gl.REPLACE : gl.ZERO, gl.KEEP, gl.KEEP);
if (node.alphaThreshold < 1) { //TODO desktop
- var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
- var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S);
+ var program = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLORALPHATEST);
+ var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S);
// set our alphaThreshold
cc.glUseProgram(program.getProgram());
program.setUniformLocationWith1f(alphaValueLocation, node.alphaThreshold);
diff --git a/cocos2d/core/CCCamera.js b/cocos2d/core/CCCamera.js
index 204e266504..de35d78e95 100644
--- a/cocos2d/core/CCCamera.js
+++ b/cocos2d/core/CCCamera.js
@@ -278,5 +278,5 @@ cc.Camera = cc._Class.extend({
* @return {Number}
*/
cc.Camera.getZEye = function () {
- return cc.FLT_EPSILON;
+ return cc.Macro.FLT_EPSILON;
};
diff --git a/cocos2d/core/CCConfiguration.js b/cocos2d/core/CCConfiguration.js
index ec90b5f533..519b12650a 100644
--- a/cocos2d/core/CCConfiguration.js
+++ b/cocos2d/core/CCConfiguration.js
@@ -91,7 +91,7 @@ cc.configuration = /** @lends cc.configuration# */{
var locValueDict = this._valueDict;
locValueDict["cocos2d.x.version"] = cc.ENGINE_VERSION;
locValueDict["cocos2d.x.compiled_with_profiler"] = false;
- locValueDict["cocos2d.x.compiled_with_gl_state_cache"] = cc.ENABLE_GL_STATE_CACHE;
+ locValueDict["cocos2d.x.compiled_with_gl_state_cache"] = cc.Macro.ENABLE_GL_STATE_CACHE;
this._inited = true;
},
@@ -220,7 +220,7 @@ cc.configuration = /** @lends cc.configuration# */{
* Dumps the current configuration on the console
*/
dumpInfo: function(){
- if(cc.ENABLE_GL_STATE_CACHE === 0){
+ if(cc.Macro.ENABLE_GL_STATE_CACHE === 0){
cc.log("");
cc.log(cc._LogInfos.configuration.dumpInfo);
cc.log("")
diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js
index a2f1cdd4d0..3ee7064c32 100644
--- a/cocos2d/core/CCDirectorWebGL.js
+++ b/cocos2d/core/CCDirectorWebGL.js
@@ -250,9 +250,9 @@ cc.game.once(cc.game.EVENT_RENDERER_INITED, function () {
_p.setAlphaBlending = function (on) {
if (on)
- cc.glBlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
+ cc.glBlendFunc(cc.Macro.BLEND_SRC, cc.Macro.BLEND_DST);
else
- cc.glBlendFunc(cc._renderContext.ONE, cc._renderContext.ZERO);
+ cc.glBlendFunc(cc.Macro.ONE, cc.Macro.ZERO);
//cc.checkGLErrorDebug();
};
diff --git a/cocos2d/core/CCDrawingPrimitivesCanvas.js b/cocos2d/core/CCDrawingPrimitivesCanvas.js
index 7ac37e5770..ccd16b324a 100644
--- a/cocos2d/core/CCDrawingPrimitivesCanvas.js
+++ b/cocos2d/core/CCDrawingPrimitivesCanvas.js
@@ -23,11 +23,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-/**
- * @const
- * @type {number}
- */
-cc.PI2 = Math.PI * 2;
/**
* Canvas of DrawingPrimitive implement version use for canvasMode
@@ -365,7 +360,7 @@ cc.DrawingPrimitiveCanvas = cc._Class.extend(/** @lends cc.DrawingPrimitiveCanva
//context.fillStyle = g1;
context.beginPath();
var startAngle_1 = 0;
- var endAngle_1 = cc.PI2;
+ var endAngle_1 = cc.Macro.PI2;
context.arc(0, 0, radius - subRadius, startAngle_1, endAngle_1, false);
context.closePath();
context.fill();
@@ -393,7 +388,7 @@ cc.DrawingPrimitiveCanvas = cc._Class.extend(/** @lends cc.DrawingPrimitiveCanva
//context.fillStyle = g1;
context.beginPath();
var startAngle_1 = 0;
- var endAngle_1 = cc.PI2;
+ var endAngle_1 = cc.Macro.PI2;
context.arc(0, 0, radius, startAngle_1, endAngle_1, false);
context.closePath();
context.fill();
diff --git a/cocos2d/core/CCDrawingPrimitivesWebGL.js b/cocos2d/core/CCDrawingPrimitivesWebGL.js
index 4c3a75c0ee..90d1c4c949 100644
--- a/cocos2d/core/CCDrawingPrimitivesWebGL.js
+++ b/cocos2d/core/CCDrawingPrimitivesWebGL.js
@@ -58,7 +58,7 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
//
// Position and 1 color passed as a uniform (to similate glColor4ub )
//
- _t._shader = cc.shaderCache.programForKey(cc.SHADER_POSITION_UCOLOR);
+ _t._shader = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_UCOLOR);
_t._colorLocation = _t._renderContext.getUniformLocation(_t._shader.getProgram(), "u_color");
_t._pointSizeLocation = _t._renderContext.getUniformLocation(_t._shader.getProgram(), "u_pointSize");
@@ -83,14 +83,14 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
var glContext = this._renderContext;
this._shader.use();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
glContext.uniform4fv(this._colorLocation, this._colorArray);
this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
var pointBuffer = glContext.createBuffer();
glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer);
glContext.bufferData(glContext.ARRAY_BUFFER, new Float32Array([point.x, point.y]), glContext.STATIC_DRAW);
- glContext.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
+ glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
glContext.drawArrays(glContext.POINTS, 0, 1);
glContext.deleteBuffer(pointBuffer);
@@ -112,14 +112,14 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
var glContext = this._renderContext;
this._shader.use();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
glContext.uniform4fv(this._colorLocation, this._colorArray);
this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
var pointBuffer = glContext.createBuffer();
glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer);
glContext.bufferData(glContext.ARRAY_BUFFER, this._pointsToTypeArray(points), glContext.STATIC_DRAW);
- glContext.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
+ glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
glContext.drawArrays(glContext.POINTS, 0, points.length);
glContext.deleteBuffer(pointBuffer);
@@ -147,13 +147,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
var glContext = this._renderContext;
this._shader.use();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
glContext.uniform4fv(this._colorLocation, this._colorArray);
var pointBuffer = glContext.createBuffer();
glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer);
glContext.bufferData(glContext.ARRAY_BUFFER, this._pointsToTypeArray([origin, destination]), glContext.STATIC_DRAW);
- glContext.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
+ glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
glContext.drawArrays(glContext.LINES, 0, 2);
glContext.deleteBuffer(pointBuffer);
@@ -202,13 +202,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
var glContext = this._renderContext;
this._shader.use();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
glContext.uniform4fv(this._colorLocation, this._colorArray);
var pointBuffer = glContext.createBuffer();
glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer);
glContext.bufferData(glContext.ARRAY_BUFFER, this._pointsToTypeArray(vertices), glContext.STATIC_DRAW);
- glContext.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
+ glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
if (closePolygon)
glContext.drawArrays(glContext.LINE_LOOP, 0, vertices.length);
@@ -233,13 +233,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
var glContext = this._renderContext;
this._shader.use();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
glContext.uniform4fv(this._colorLocation, this._colorArray);
var pointBuffer = glContext.createBuffer();
glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer);
glContext.bufferData(glContext.ARRAY_BUFFER, this._pointsToTypeArray(poli), glContext.STATIC_DRAW);
- glContext.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
+ glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
glContext.drawArrays(glContext.TRIANGLE_FAN, 0, poli.length);
glContext.deleteBuffer(pointBuffer);
@@ -281,13 +281,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
var glContext = this._renderContext;
this._shader.use();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
glContext.uniform4fv(this._colorLocation, this._colorArray);
var pointBuffer = glContext.createBuffer();
glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer);
glContext.bufferData(glContext.ARRAY_BUFFER, vertices, glContext.STATIC_DRAW);
- glContext.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
+ glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
glContext.drawArrays(glContext.LINE_STRIP, 0, segments + additionalSegment);
glContext.deleteBuffer(pointBuffer);
@@ -319,13 +319,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
var glContext = this._renderContext;
this._shader.use();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
glContext.uniform4fv(this._colorLocation, this._colorArray);
var pointBuffer = glContext.createBuffer();
glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer);
glContext.bufferData(glContext.ARRAY_BUFFER, vertices, glContext.STATIC_DRAW);
- glContext.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
+ glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
glContext.drawArrays(glContext.LINE_STRIP, 0, segments + 1);
glContext.deleteBuffer(pointBuffer);
@@ -358,13 +358,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
var glContext = this._renderContext;
this._shader.use();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
glContext.uniform4fv(this._colorLocation, this._colorArray);
var pointBuffer = glContext.createBuffer();
glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer);
glContext.bufferData(glContext.ARRAY_BUFFER, vertices, glContext.STATIC_DRAW);
- glContext.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
+ glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
glContext.drawArrays(glContext.LINE_STRIP, 0, segments + 1);
glContext.deleteBuffer(pointBuffer);
@@ -418,13 +418,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL#
var glContext = this._renderContext;
this._shader.use();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
glContext.uniform4fv(this._colorLocation, this._colorArray);
var pointBuffer = glContext.createBuffer();
glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer);
glContext.bufferData(glContext.ARRAY_BUFFER, vertices, glContext.STATIC_DRAW);
- glContext.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
+ glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0);
glContext.drawArrays(glContext.LINE_STRIP, 0, segments + 1);
glContext.deleteBuffer(pointBuffer);
diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js
index 815490433a..37bdffac25 100644
--- a/cocos2d/core/CCScheduler.js
+++ b/cocos2d/core/CCScheduler.js
@@ -124,7 +124,7 @@ cc.Timer = cc._Class.extend(/** @lends cc.Timer# */{
this._delay = delay;
this._useDelay = (this._delay > 0);
this._repeat = repeat;
- this._runForever = (this._repeat === cc.REPEAT_FOREVER);
+ this._runForever = (this._repeat === cc.Macro.REPEAT_FOREVER);
},
trigger: function(){
@@ -519,7 +519,7 @@ cc.Scheduler = cc._Class.extend(/** @lends cc.Scheduler# */{
* If paused is YES, then it won't be called until it is resumed.
* If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
* If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
- * repeat let the action be repeated repeat + 1 times, use cc.REPEAT_FOREVER to let the action run continuously
+ * repeat let the action be repeated repeat + 1 times, use cc.Macro.REPEAT_FOREVER to let the action run continuously
* delay is the amount of time the action will wait before it'll start
*
- * If enabled, the texture coordinates will be calculated by using this formula:
- * - texCoord.left = (rect.x*2+1) / (texture.wide*2);
- * - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
- *
- * The same for bottom and top.
- *
- * This formula prevents artifacts by using 99% of the texture.
- * The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.
- *
- * Affected nodes:
- * - _ccsg.Sprite / cc.SpriteBatchNode and subclasses: cc.LabelBMFont, cc.TMXTiledMap
- * - cc.LabelAtlas
- * - cc.QuadParticleSystem
- * - cc.TileMap
- *
- * To enabled set it to 1. Disabled by default.
- * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- *
- * Seconds between FPS updates.
- * 0.5 seconds, means that the FPS number will be updated every 0.5 seconds.
- * Having a bigger number means a more reliable FPS
- *
- * Default value: 0.1f
- * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- *
- * If enabled, the ccsg.Node objects (_ccsg.Sprite, _ccsg.Label,etc) will be able to render in subpixels.
- * If disabled, integer pixels will be used.
- *
- * To enable set it to 1. Enabled by default.
- * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- *
- * If enabled, the _ccsg.Sprite objects rendered with cc.SpriteBatchNode will be able to render in subpixels.
- * If disabled, integer pixels will be used.
- *
- * To enable set it to 1. Enabled by default.
- * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- *
- * Automatically premultiply alpha for PNG resources - *
- * @property {Number} AUTO_PREMULTIPLIED_ALPHA_FOR_PNG - * @readonly - */ -cc.AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0; - -/** - *
- * If most of your images have pre-multiplied alpha, set it to 1 (if you are going to use .PNG/.JPG file images).
- * Only set to 0 if ALL your images by-pass Apple UIImage loading system (eg: if you use libpng or PVR images)
- *
- * To enable set it to a value different than 0. Enabled by default.
- * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- *
- * Use GL_TRIANGLE_STRIP instead of GL_TRIANGLES when rendering the texture atlas.
- * It seems it is the recommend way, but it is much slower, so, enable it at your own risk
- *
- * To enable set it to a value different than 0. Disabled by default.
- * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- *
- * By default, cc.TextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).
- * Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.
- * So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.
- *
- * To disable it set it to 0. disable by default.(Not Supported on WebGL)
- * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- *
- * If enabled, NPOT textures will be used where available. Only 3rd gen (and newer) devices support NPOT textures.
- * NPOT textures have the following limitations:
- * - They can't have mipmaps
- * - They only accept GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}
- *
- * To enable set it to a value different than 0. Disabled by default.
- *
- * This value governs only the PNG, GIF, BMP, images.
- * This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.
- * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- *
- * If enabled, cocos2d supports retina display.
- * For performance reasons, it's recommended disable it in games without retina display support, like iPad only games.
- *
- * To enable set it to 1. Use 0 to disable it. Enabled by default.
- *
- * This value governs only the PNG, GIF, BMP, images.
- * This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.
- * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- *
- * It's the suffix that will be appended to the files in order to load "retina display" images.
- *
- * On an iPhone4 with Retina Display support enabled, the file @"sprite-hd.png" will be loaded instead of @"sprite.png".
- * If the file doesn't exist it will use the non-retina display image.
- *
- * Platforms: Only used on Retina Display devices like iPhone 4.
- *
- * If enabled, it will use LA88 (Luminance Alpha 16-bit textures) for CCLabelTTF objects.
- * If it is disabled, it will use A8 (Alpha 8-bit textures).
- * LA88 textures are 6% faster than A8 textures, but they will consume 2x memory.
- *
- * This feature is enabled by default.
- *
- * If enabled, all subclasses of _ccsg.Sprite will draw a bounding box
- * Useful for debugging purposes only. It is recommend to leave it disabled.
- *
- * To enable set it to a value different than 0. Disabled by default:
- * 0 -- disabled
- * 1 -- draw bounding box
- * 2 -- draw texture box
- *
- * If enabled, all subclasses of _ccsg.Sprite that are rendered using an cc.SpriteBatchNode draw a bounding box.
- * Useful for debugging purposes only. It is recommend to leave it disabled.
- *
- * To enable set it to a value different than 0. Disabled by default.
- *
- * If enabled, all subclasses of cc.LabelBMFont will draw a bounding box
- * Useful for debugging purposes only. It is recommend to leave it disabled.
- *
- * To enable set it to a value different than 0. Disabled by default.
- *
- * If enabled, all subclasses of cc.LabelAtlas will draw a bounding box
- * Useful for debugging purposes only. It is recommend to leave it disabled.
- *
- * To enable set it to a value different than 0. Disabled by default.
- *
- * If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
- * If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
- * If disabled, only the last run action will take effect.
- *
- * If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches.
- * In order to use them, you have to use the following functions, instead of the the GL ones:
- * - ccGLUseProgram() instead of glUseProgram()
- * - ccGLDeleteProgram() instead of glDeleteProgram()
- * - ccGLBlendFunc() instead of glBlendFunc()
- *
- * If this functionality is disabled, then ccGLUseProgram(), ccGLDeleteProgram(), ccGLBlendFunc() will call the GL ones, without using the cache.
- * It is recommend to enable whenever possible to improve speed.
- * If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on.
- *
- * simple macro that swaps 2 variables
- * modified from c++ macro, you need to pass in the x and y variables names in string,
- * and then a reference to the whole object as third variable
- *
+ * If enabled, the texture coordinates will be calculated by using this formula:
+ * - texCoord.left = (rect.x*2+1) / (texture.wide*2);
+ * - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
+ *
+ * The same for bottom and top.
+ *
+ * This formula prevents artifacts by using 99% of the texture.
+ * The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.
+ *
+ * Affected nodes:
+ * - _ccsg.Sprite / cc.SpriteBatchNode and subclasses: cc.LabelBMFont, _ccsg.TMXTiledMap
+ * - cc.LabelAtlas
+ * - cc.QuadParticleSystem
+ * - cc.TileMap
+ *
+ * To enabled set it to 1. Disabled by default.
+ * To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
+ *
+ * Seconds between FPS updates.
+ * 0.5 seconds, means that the FPS number will be updated every 0.5 seconds.
+ * Having a bigger number means a more reliable FPS
+ *
+ * Default value: 0.1f
+ * To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
+ *
+ * If enabled, the ccsg.Node objects (_ccsg.Sprite, _ccsg.Label,etc) will be able to render in subpixels.
+ * If disabled, integer pixels will be used.
+ *
+ * To enable set it to 1. Enabled by default.
+ * To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
+ *
+ * If enabled, the _ccsg.Sprite objects rendered with cc.SpriteBatchNode will be able to render in subpixels.
+ * If disabled, integer pixels will be used.
+ *
+ * To enable set it to 1. Enabled by default.
+ * To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
+ *
+ * Automatically premultiply alpha for PNG resources + *
+ * @property {Number} AUTO_PREMULTIPLIED_ALPHA_FOR_PNG + * @readonly + */ + AUTO_PREMULTIPLIED_ALPHA_FOR_PNG: 0, + + /** + *
+ * If most of your images have pre-multiplied alpha, set it to 1 (if you are going to use .PNG/.JPG file images).
+ * Only set to 0 if ALL your images by-pass Apple UIImage loading system (eg: if you use libpng or PVR images)
+ *
+ * To enable set it to a value different than 0. Enabled by default.
+ * To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
+ *
+ * Use GL_TRIANGLE_STRIP instead of GL_TRIANGLES when rendering the texture atlas.
+ * It seems it is the recommend way, but it is much slower, so, enable it at your own risk
+ *
+ * To enable set it to a value different than 0. Disabled by default.
+ * To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
+ *
+ * By default, cc.TextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).
+ * Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.
+ * So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.
+ *
+ * To disable it set it to 0. disable by default.(Not Supported on WebGL)
+ * To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
+ *
+ * If enabled, NPOT textures will be used where available. Only 3rd gen (and newer) devices support NPOT textures.
+ * NPOT textures have the following limitations:
+ * - They can't have mipmaps
+ * - They only accept GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}
+ *
+ * To enable set it to a value different than 0. Disabled by default.
+ *
+ * This value governs only the PNG, GIF, BMP, images.
+ * This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.
+ * To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
+ *
+ * If enabled, it will use LA88 (Luminance Alpha 16-bit textures) for CCLabelTTF objects.
+ * If it is disabled, it will use A8 (Alpha 8-bit textures).
+ * LA88 textures are 6% faster than A8 textures, but they will consume 2x memory.
+ *
+ * This feature is enabled by default.
+ *
+ * If enabled, all subclasses of _ccsg.Sprite will draw a bounding box
+ * Useful for debugging purposes only. It is recommend to leave it disabled.
+ *
+ * To enable set it to a value different than 0. Disabled by default:
+ * 0 -- disabled
+ * 1 -- draw bounding box
+ * 2 -- draw texture box
+ *
+ * If enabled, all subclasses of cc.LabelBMFont will draw a bounding box
+ * Useful for debugging purposes only. It is recommend to leave it disabled.
+ *
+ * To enable set it to a value different than 0. Disabled by default.
+ *
+ * If enabled, all subclasses of cc.LabelAtlas will draw a bounding box
+ * Useful for debugging purposes only. It is recommend to leave it disabled.
+ *
+ * To enable set it to a value different than 0. Disabled by default.
+ *
+ * If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
+ * If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
+ * If disabled, only the last run action will take effect.
+ *
+ * If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches.
+ * In order to use them, you have to use the following functions, instead of the the GL ones:
+ * - ccGLUseProgram() instead of glUseProgram()
+ * - ccGLDeleteProgram() instead of glDeleteProgram()
+ * - ccGLBlendFunc() instead of glBlendFunc()
+ *
+ * If this functionality is disabled, then ccGLUseProgram(), ccGLDeleteProgram(), ccGLBlendFunc() will call the GL ones, without using the cache.
+ * It is recommend to enable whenever possible to improve speed.
+ * If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on.
+ *
* Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end @@ -121,13 +1591,6 @@ cc.randomMinus1To1 = function () { return (Math.random() - 0.5) * 2; }; -/** - * returns a random float between 0 and 1 - * @return {Number} - * @method random0To1 - */ -cc.random0To1 = Math.random; - /** * converts degrees to radians * @param {Number} angle @@ -135,7 +1598,7 @@ cc.random0To1 = Math.random; * @method degreesToRadians */ cc.degreesToRadians = function (angle) { - return angle * cc.RAD; + return angle * cc.Macro.RAD; }; /** @@ -145,24 +1608,8 @@ cc.degreesToRadians = function (angle) { * @method radiansToDegrees */ cc.radiansToDegrees = function (angle) { - return angle * cc.DEG; + return angle * cc.Macro.DEG; }; -/** - * converts radians to degrees - * @param {Number} angle - * @return {Number} - * @method radiansToDegress - */ -cc.radiansToDegress = function (angle) { - cc.log(cc._LogInfos.radiansToDegress); - return angle * cc.DEG; -}; - -/** - * @property {Number} REPEAT_FOREVER - * @readonly - */ -cc.REPEAT_FOREVER = cc.sys.isNative ? 0xffffffff : (Number.MAX_VALUE - 1); /** * Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix @@ -178,7 +1625,7 @@ cc.nodeDrawSetup = function (node) { } }; -/** +/* *
* GL states that are enabled:
* - GL_TEXTURE_2D
@@ -188,16 +1635,16 @@ cc.nodeDrawSetup = function (node) {
*
* Disable default GL states:
* - GL_TEXTURE_2D
@@ -206,7 +1653,7 @@ cc.enableDefaultGLStates = function () {
*
@@ -228,120 +1675,6 @@ cc.incrementGLDraws = function (addNumber) {
cc.g_NumberOfDraws += addNumber;
};
-/**
- * @property {Number} FLT_EPSILON
- * @readonly
- */
-cc.FLT_EPSILON = 0.0000001192092896;
-
-//some gl constant variable
-/**
- * @property {Number} ONE
- * @readonly
- */
-cc.ONE = 1;
-
-/**
- * @property {Number} ZERO
- * @readonly
- */
-cc.ZERO = 0;
-
-/**
- * @property {Number} SRC_ALPHA
- * @readonly
- */
-cc.SRC_ALPHA = 0x0302;
-
-/**
- * @property {Number} SRC_ALPHA_SATURATE
- * @readonly
- */
-cc.SRC_ALPHA_SATURATE = 0x308;
-
-/**
- * @property {Number} SRC_COLOR
- * @readonly
- */
-cc.SRC_COLOR = 0x300;
-
-/**
- * @property {Number} DST_ALPHA
- * @readonly
- */
-cc.DST_ALPHA = 0x304;
-
-/**
- * @property {Number} DST_COLOR
- * @readonly
- */
-cc.DST_COLOR = 0x306;
-
-/**
- * @property {Number} ONE_MINUS_SRC_ALPHA
- * @readonly
- */
-cc.ONE_MINUS_SRC_ALPHA = 0x0303;
-
-/**
- * @property {Number} ONE_MINUS_SRC_COLOR
- * @readonly
- */
-cc.ONE_MINUS_SRC_COLOR = 0x301;
-
-/**
- * @property {Number} ONE_MINUS_DST_ALPHA
- * @readonly
- */
-cc.ONE_MINUS_DST_ALPHA = 0x305;
-
-/**
- * @property {Number} ONE_MINUS_DST_COLOR
- * @readonly
- */
-cc.ONE_MINUS_DST_COLOR = 0x0307;
-
-/**
- * @property {Number} ONE_MINUS_CONSTANT_ALPHA
- * @readonly
- */
-cc.ONE_MINUS_CONSTANT_ALPHA = 0x8004;
-
-/**
- * @property {Number} ONE_MINUS_CONSTANT_COLOR
- * @readonly
- */
-cc.ONE_MINUS_CONSTANT_COLOR = 0x8002;
-
-/**
- * the constant variable equals gl.LINEAR for texture
- * @property {Number} LINEAR
- * @readonly
- */
-cc.LINEAR = 0x2601;
-
-/**
- * default gl blend src function. Compatible with premultiplied alpha images.
- * @property {Number} BLEND_SRC
- * @readonly
- */
-cc.defineGetterSetter(cc, "BLEND_SRC", function (){
- if (cc._renderType === cc.game.RENDER_TYPE_WEBGL
- && cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA) {
- return cc.ONE;
- }
- else {
- return cc.SRC_ALPHA;
- }
-});
-
-/**
- * default gl blend dst function. Compatible with premultiplied alpha images.
- * @property {Number} BLEND_DST
- * @readonly
- */
-cc.BLEND_DST = 0x0303;
-
/**
* Check webgl error.Error will be shown in console if exists.
* @method checkGLErrorDebug
@@ -354,290 +1687,3 @@ cc.checkGLErrorDebug = function () {
}
}
};
-
-//Possible device orientations
-/**
- * Device oriented vertically, home button on the bottom (UIDeviceOrientationPortrait)
- * @property {Number} DEVICE_ORIENTATION_PORTRAIT
- * @readonly
- */
-cc.DEVICE_ORIENTATION_PORTRAIT = 0;
-
-/**
- * Device oriented horizontally, home button on the right (UIDeviceOrientationLandscapeLeft)
- * @property {Number} DEVICE_ORIENTATION_LANDSCAPE_LEFT
- * @readonly
- */
-cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1;
-
-/**
- * Device oriented vertically, home button on the top (UIDeviceOrientationPortraitUpsideDown)
- * @property {Number} DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN
- * @readonly
- */
-cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2;
-
-/**
- * Device oriented horizontally, home button on the left (UIDeviceOrientationLandscapeRight)
- * @property {Number} DEVICE_ORIENTATION_LANDSCAPE_RIGHT
- * @readonly
- */
-cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3;
-
-/**
- * In browsers, we only support 2 orientations by change window size.
- * @property {Number} DEVICE_MAX_ORIENTATIONS
- * @readonly
- */
-cc.DEVICE_MAX_ORIENTATIONS = 2;
-
-
-// ------------------- vertex attrib flags -----------------------------
-/**
- * @property {Number} VERTEX_ATTRIB_FLAG_NONE
- * @readonly
- */
-cc.VERTEX_ATTRIB_FLAG_NONE = 0;
-/**
- * @property {Number} VERTEX_ATTRIB_FLAG_POSITION
- * @readonly
- */
-cc.VERTEX_ATTRIB_FLAG_POSITION = 1 << 0;
-/**
- * @property {Number} VERTEX_ATTRIB_FLAG_COLOR
- * @readonly
- */
-cc.VERTEX_ATTRIB_FLAG_COLOR = 1 << 1;
-/**
- * @property {Number} VERTEX_ATTRIB_FLAG_TEX_COORDS
- * @readonly
- */
-cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 1 << 2;
-/**
- * @property {Number} VERTEX_ATTRIB_FLAG_POS_COLOR_TEX
- * @readonly
- */
-cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = ( cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS );
-
-/**
- * GL server side states
- * @property {Number} GL_ALL
- * @readonly
- */
-cc.GL_ALL = 0;
-
-//-------------Vertex Attributes-----------
-/**
- * @property {Number} VERTEX_ATTRIB_POSITION
- * @readonly
- */
-cc.VERTEX_ATTRIB_POSITION = 0;
-/**
- * @property {Number} VERTEX_ATTRIB_COLOR
- * @readonly
- */
-cc.VERTEX_ATTRIB_COLOR = 1;
-/**
- * @property {Number} VERTEX_ATTRIB_TEX_COORDS
- * @readonly
- */
-cc.VERTEX_ATTRIB_TEX_COORDS = 2;
-/**
- * @property {Number} VERTEX_ATTRIB_MAX
- * @readonly
- */
-cc.VERTEX_ATTRIB_MAX = 3;
-
-//------------Uniforms------------------
-/**
- * @property {Number} UNIFORM_PMATRIX
- * @readonly
- */
-cc.UNIFORM_PMATRIX = 0;
-/**
- * @property {Number} UNIFORM_MVMATRIX
- * @readonly
- */
-cc.UNIFORM_MVMATRIX = 1;
-/**
- * @property {Number} UNIFORM_MVPMATRIX
- * @readonly
- */
-cc.UNIFORM_MVPMATRIX = 2;
-/**
- * @property {Number} UNIFORM_TIME
- * @readonly
- */
-cc.UNIFORM_TIME = 3;
-/**
- * @property {Number} UNIFORM_SINTIME
- * @readonly
- */
-cc.UNIFORM_SINTIME = 4;
-/**
- * @property {Number} UNIFORM_COSTIME
- * @readonly
- */
-cc.UNIFORM_COSTIME = 5;
-/**
- * @property {Number} UNIFORM_RANDOM01
- * @readonly
- */
-cc.UNIFORM_RANDOM01 = 6;
-/**
- * @property {Number} UNIFORM_SAMPLER
- * @readonly
- */
-cc.UNIFORM_SAMPLER = 7;
-/**
- * @property {Number} UNIFORM_MAX
- * @readonly
- */
-cc.UNIFORM_MAX = 8;
-
-//------------Shader Name---------------
-/**
- * @property {String} SHADER_POSITION_TEXTURECOLOR
- * @readonly
- */
-cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor";
-/**
- * @property {String} SHADER_POSITION_TEXTURECOLORALPHATEST
- * @readonly
- */
-cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest";
-/**
- * @property {String} SHADER_POSITION_COLOR
- * @readonly
- */
-cc.SHADER_POSITION_COLOR = "ShaderPositionColor";
-/**
- * @property {String} SHADER_POSITION_TEXTURE
- * @readonly
- */
-cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture";
-/**
- * @property {String} SHADER_POSITION_TEXTURE_UCOLOR
- * @readonly
- */
-cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor";
-/**
- * @property {String} SHADER_POSITION_TEXTUREA8COLOR
- * @readonly
- */
-cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color";
-/**
- * @property {String} SHADER_POSITION_UCOLOR
- * @readonly
- */
-cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor";
-/**
- * @property {String} SHADER_POSITION_LENGTHTEXTURECOLOR
- * @readonly
- */
-cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor";
-
-//------------uniform names----------------
-/**
- * @property {String} UNIFORM_PMATRIX_S
- * @readonly
- */
-cc.UNIFORM_PMATRIX_S = "CC_PMatrix";
-/**
- * @property {String} UNIFORM_MVMATRIX_S
- * @readonly
- */
-cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix";
-/**
- * @property {String} UNIFORM_MVPMATRIX_S
- * @readonly
- */
-cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix";
-/**
- * @property {String} UNIFORM_TIME_S
- * @readonly
- */
-cc.UNIFORM_TIME_S = "CC_Time";
-/**
- * @property {String} UNIFORM_SINTIME_S
- * @readonly
- */
-cc.UNIFORM_SINTIME_S = "CC_SinTime";
-/**
- * @property {String} UNIFORM_COSTIME_S
- * @readonly
- */
-cc.UNIFORM_COSTIME_S = "CC_CosTime";
-/**
- * @property {String} UNIFORM_RANDOM01_S
- * @readonly
- */
-cc.UNIFORM_RANDOM01_S = "CC_Random01";
-/**
- * @property {String} UNIFORM_SAMPLER_S
- * @readonly
- */
-cc.UNIFORM_SAMPLER_S = "CC_Texture0";
-/**
- * @property {String} UNIFORM_ALPHA_TEST_VALUE_S
- * @readonly
- */
-cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value";
-
-//------------Attribute names--------------
-/**
- * @property {String} ATTRIBUTE_NAME_COLOR
- * @readonly
- */
-cc.ATTRIBUTE_NAME_COLOR = "a_color";
-/**
- * @property {String} ATTRIBUTE_NAME_POSITION
- * @readonly
- */
-cc.ATTRIBUTE_NAME_POSITION = "a_position";
-/**
- * @property {String} ATTRIBUTE_NAME_TEX_COORD
- * @readonly
- */
-cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
-
-
-/**
- * default size for font size
- * @property {Number} ITEM_SIZE
- * @readonly
- */
-cc.ITEM_SIZE = 32;
-
-/**
- * default tag for current item
- * @property {Number} CURRENT_ITEM
- * @readonly
- */
-cc.CURRENT_ITEM = 0xc0c05001;
-/**
- * default tag for zoom action tag
- * @property {Number} ZOOM_ACTION_TAG
- * @readonly
- */
-cc.ZOOM_ACTION_TAG = 0xc0c05002;
-/**
- * default tag for normal
- * @property {Number} NORMAL_TAG
- * @readonly
- */
-cc.NORMAL_TAG = 8801;
-
-/**
- * default selected tag
- * @property {Number} SELECTED_TAG
- * @readonly
- */
-cc.SELECTED_TAG = 8802;
-
-/**
- * default disabled tag
- * @property {Number} DISABLE_TAG
- * @readonly
- */
-cc.DISABLE_TAG = 8803;
diff --git a/cocos2d/core/platform/js.js b/cocos2d/core/platform/js.js
index f4a1d5f162..ee1294934a 100644
--- a/cocos2d/core/platform/js.js
+++ b/cocos2d/core/platform/js.js
@@ -529,6 +529,49 @@ js.obsoletes = function (obj, objName, props, writable) {
}
};
+/**
+ * A string tool to construct a string with format string.
+ * for example:
+ * cc.js.formatStr("a: %d, b: %b", a, b);
+ * cc.js.formatStr(a, b, c);
+ * @returns {String}
+ */
+js.formatStr = function formatStr() {
+ 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;
+};
+
/**
* @class array
* @static
diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js
index 6246e0b73c..613150fcdb 100644
--- a/cocos2d/core/sprites/CCAnimationCache.js
+++ b/cocos2d/core/sprites/CCAnimationCache.js
@@ -172,7 +172,7 @@ cc.spriteFrameAnimationCache = {
var isLoop = animationDict["loop"];
var loopsTemp = parseInt(animationDict["loops"]);
- var loops = isLoop ? cc.REPEAT_FOREVER : ((isNaN(loopsTemp)) ? 1 : loopsTemp);
+ var loops = isLoop ? cc.Macro.REPEAT_FOREVER : ((isNaN(loopsTemp)) ? 1 : loopsTemp);
var restoreOriginalFrame = (animationDict["restoreOriginalFrame"] && animationDict["restoreOriginalFrame"] == true) ? true : false;
var frameArray = animationDict["frames"];
diff --git a/cocos2d/core/sprites/CCSGSprite.js b/cocos2d/core/sprites/CCSGSprite.js
index e8d8ead0fd..818c7ae057 100644
--- a/cocos2d/core/sprites/CCSGSprite.js
+++ b/cocos2d/core/sprites/CCSGSprite.js
@@ -130,7 +130,7 @@ _ccsg.Sprite = _ccsg.Node.extend({
self._shouldBeHidden = false;
self._offsetPosition = cc.p(0, 0);
self._unflippedOffsetPositionFromCenter = cc.p(0, 0);
- self._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST};
+ self._blendFunc = {src: cc.Macro.BLEND_SRC, dst: cc.Macro.BLEND_DST};
self._rect = cc.rect(0, 0, 0, 0);
self._softInit(fileName, rect, rotated);
@@ -627,8 +627,8 @@ _ccsg.Sprite = _ccsg.Node.extend({
_ccsg.Node.prototype.init.call(_t);
_t.dirty = _t._recursiveDirty = false;
- _t._blendFunc.src = cc.BLEND_SRC;
- _t._blendFunc.dst = cc.BLEND_DST;
+ _t._blendFunc.src = cc.Macro.BLEND_SRC;
+ _t._blendFunc.dst = cc.Macro.BLEND_DST;
_t.texture = null;
_t._flippedX = _t._flippedY = false;
@@ -704,8 +704,8 @@ _ccsg.Sprite = _ccsg.Node.extend({
_t.dirty = false;
_t._opacityModifyRGB = true;
- _t._blendFunc.src = cc.BLEND_SRC;
- _t._blendFunc.dst = cc.BLEND_DST;
+ _t._blendFunc.src = cc.Macro.BLEND_SRC;
+ _t._blendFunc.dst = cc.Macro.BLEND_DST;
_t._flippedX = _t._flippedY = false;
diff --git a/cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js
index 60ebb6a47f..eeba97d680 100644
--- a/cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js
+++ b/cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js
@@ -155,7 +155,7 @@
var left, right, top, bottom, tempSwap, locQuad = this._quad;
if (node._rectRotated) {
- if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) {
+ if (cc.Macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) {
left = (2 * rect.x + 1) / (2 * atlasWidth);
right = left + (rect.height * 2 - 2) / (2 * atlasWidth);
top = (2 * rect.y + 1) / (2 * atlasHeight);
@@ -188,7 +188,7 @@
locQuad.tr.texCoords.u = right;
locQuad.tr.texCoords.v = bottom;
} else {
- if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) {
+ if (cc.Macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) {
left = (2 * rect.x + 1) / (2 * atlasWidth);
right = left + (rect.width * 2 - 2) / (2 * atlasWidth);
top = (2 * rect.y + 1) / (2 * atlasHeight);
@@ -279,12 +279,12 @@
// it's possible to have an untextured sprite
var node = this._node;
if (!node._texture || !node._texture.hasPremultipliedAlpha()) {
- node._blendFunc.src = cc.SRC_ALPHA;
- node._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA;
+ node._blendFunc.src = cc.Macro.SRC_ALPHA;
+ node._blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA;
node.opacityModifyRGB = false;
} else {
- node._blendFunc.src = cc.BLEND_SRC;
- node._blendFunc.dst = cc.BLEND_DST;
+ node._blendFunc.src = cc.Macro.BLEND_SRC;
+ node._blendFunc.dst = cc.Macro.BLEND_DST;
node.opacityModifyRGB = true;
}
};
@@ -306,9 +306,9 @@
}
if (texture)
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
+ this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR);
else
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR);
+ this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_COLOR);
};
@@ -365,7 +365,7 @@
var dy = x1 * sr + y2 * cr2 + y;
var locVertexZ = node._vertexZ;
- if (!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) {
+ if (!cc.Macro.SPRITEBATCHNODE_RENDER_SUBPIXEL) {
ax = 0 | ax;
ay = 0 | ay;
bx = 0 | bx;
@@ -389,7 +389,7 @@
if (node._hasChildren)
node._arrayMakeObjectsPerformSelector(node._children, _ccsg.Node._stateCallbackType.updateTransform);
- /*if (cc.SPRITE_DEBUG_DRAW) { //TODO
+ /*if (cc.Macro.SPRITE_DEBUG_DRAW) { //TODO
// draw bounding box
var vertices = [
cc.p(_t._quad.bl.vertices.x, _t._quad.bl.vertices.y),
@@ -436,16 +436,16 @@
cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst);
//optimize performance for javascript
cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture);
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer);
if (this._quadDirty) {
gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW);
this._quadDirty = false;
}
- gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION
- gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR
- gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS
+ gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.Macro.VERTEX_ATTRIB_POSITION
+ gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.Macro.VERTEX_ATTRIB_COLOR
+ gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.Macro.VERTEX_ATTRIB_TEX_COORDS
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
}
} else {
@@ -455,20 +455,20 @@
cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst);
cc.glBindTexture2D(null);
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION | cc.Macro.VERTEX_ATTRIB_FLAG_COLOR);
gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer);
if (this._quadDirty) {
gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.STATIC_DRAW);
this._quadDirty = false;
}
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
}
cc.g_NumberOfDraws++;
- if (cc.SPRITE_DEBUG_DRAW === 0 && !node._showNode)
+ if (cc.Macro.SPRITE_DEBUG_DRAW === 0 && !node._showNode)
return;
cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
@@ -476,7 +476,7 @@
cc.current_stack.stack.push(cc.current_stack.top);
cc.current_stack.top = this._stackMatrix;
- if (cc.SPRITE_DEBUG_DRAW === 1 || node._showNode) {
+ if (cc.Macro.SPRITE_DEBUG_DRAW === 1 || node._showNode) {
// draw bounding box
var locQuad = this._quad;
var verticesG1 = [
@@ -486,7 +486,7 @@
cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y)
];
cc._drawingUtil.drawPoly(verticesG1, 4, true);
- } else if (cc.SPRITE_DEBUG_DRAW === 2) {
+ } else if (cc.Macro.SPRITE_DEBUG_DRAW === 2) {
// draw texture box
var drawRectG2 = node.getTextureRect();
var offsetPixG2 = node.getOffsetPosition();
diff --git a/cocos2d/core/sprites/CCScale9Sprite.js b/cocos2d/core/sprites/CCScale9Sprite.js
index 8bba89cbe5..415ee6f04f 100644
--- a/cocos2d/core/sprites/CCScale9Sprite.js
+++ b/cocos2d/core/sprites/CCScale9Sprite.js
@@ -996,12 +996,12 @@ cc.Scale9Sprite = _ccsg.Node.extend({
*/
setBlendFunc: function (blendFunc, dst) {
if (dst === undefined) {
- this._blendFunc.src = blendFunc.src || cc.BLEND_SRC;
- this._blendFunc.dst = blendFunc.dst || cc.BLEND_DST;
+ this._blendFunc.src = blendFunc.src || cc.Macro.BLEND_SRC;
+ this._blendFunc.dst = blendFunc.dst || cc.Macro.BLEND_DST;
}
else {
- this._blendFunc.src = blendFunc || cc.BLEND_SRC;
- this._blendFunc.dst = dst || cc.BLEND_DST;
+ this._blendFunc.src = blendFunc || cc.Macro.BLEND_SRC;
+ this._blendFunc.dst = dst || cc.Macro.BLEND_DST;
}
},
diff --git a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
index 01857724a3..d9276a7f32 100644
--- a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
+++ b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
@@ -65,14 +65,14 @@
cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst);
//optimize performance for javascript
cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture);
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer);
var quads = node._quads;
var bufferOffset = 0;
var quadsLength = quads.length;
- if(quadsLength == 0) return;
+ if (quadsLength === 0) return;
if (needRebuildWebBuffer)
{
gl.bufferData(gl.ARRAY_BUFFER,quads[0].arrayBuffer.byteLength * quads.length, gl.DYNAMIC_DRAW);
@@ -84,9 +84,9 @@
bufferOffset = 0;
for(var i = 0; i < quads.length; ++i)
{
- gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, bufferOffset); //cc.VERTEX_ATTRIB_POSITION
- gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12 + bufferOffset); //cc.VERTEX_ATTRIB_COLOR
- gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16 + bufferOffset); //cc.VERTEX_ATTRIB_TEX_COORDS
+ gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, bufferOffset); //cc.Macro.VERTEX_ATTRIB_POSITION
+ gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12 + bufferOffset); //cc.Macro.VERTEX_ATTRIB_COLOR
+ gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16 + bufferOffset); //cc.Macro.VERTEX_ATTRIB_TEX_COORDS
if(node._isTriangle) {
gl.drawArrays(gl.TRIANGLES, 0, 3);
} else {
@@ -116,7 +116,7 @@
proto.setState = function (state) {
var node = this._node;
if (state === cc.Scale9Sprite.state.NORMAL) {
- node.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR));
+ node.setShaderProgram(cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR));
} else if (state === cc.Scale9Sprite.state.GRAY) {
node.setShaderProgram(cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram());
}
@@ -129,10 +129,10 @@
return grayShader;
grayShader = new cc.GLProgram();
- grayShader.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment);
- grayShader.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- grayShader.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
- grayShader.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
+ grayShader.initWithVertexShaderByteArray(cc.Shaders.POSITION_TEXTURE_COLOR_VERT, cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment);
+ grayShader.addAttribute(cc.Macro.ATTRIBUTE_NAME_POSITION, cc.Macro.VERTEX_ATTRIB_POSITION);
+ grayShader.addAttribute(cc.Macro.ATTRIBUTE_NAME_COLOR, cc.Macro.VERTEX_ATTRIB_COLOR);
+ grayShader.addAttribute(cc.Macro.ATTRIBUTE_NAME_TEX_COORD, cc.Macro.VERTEX_ATTRIB_TEX_COORDS);
grayShader.link();
grayShader.updateUniforms();
diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js
index 6a081e1e5a..d432f29424 100644
--- a/cocos2d/core/sprites/CCSpriteBatchNode.js
+++ b/cocos2d/core/sprites/CCSpriteBatchNode.js
@@ -64,7 +64,7 @@ cc.SpriteBatchNode = _ccsg.Node.extend(/** @lends cc.SpriteBatchNode# */{
ctor: function (fileImage, capacity) {
_ccsg.Node.prototype.ctor.call(this);
this._descendants = [];
- this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
+ this._blendFunc = new cc.BlendFunc(cc.Macro.BLEND_SRC, cc.Macro.BLEND_DST);
var texture2D;
capacity = capacity || cc.SpriteBatchNode.DEFAULT_CAPACITY;
@@ -272,7 +272,7 @@ cc.SpriteBatchNode = _ccsg.Node.extend(/** @lends cc.SpriteBatchNode# */{
// ignore parent Z if parent is spriteSheet
var ignoreParent = selParent === this;
var previous = null;
- if (childIndex > 0 && childIndex < cc.UINT_MAX)
+ if (childIndex > 0 && childIndex < cc.Macro.UINT_MAX)
previous = brothers[childIndex - 1];
// first child of the sprite sheet
diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js
index c3251a5b6b..87732bffe0 100644
--- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js
+++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js
@@ -114,7 +114,7 @@
this._textureAtlas = new cc.TextureAtlas();
this._textureAtlas.initWithTexture(texture, capacity);
this._updateBlendFunc();
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
+ this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR);
};
proto.insertQuad = function(sprite, index){
@@ -224,8 +224,8 @@
proto._updateBlendFunc = function () {
if (!this._textureAtlas.texture.hasPremultipliedAlpha()) {
var blendFunc = this._node._blendFunc;
- blendFunc.src = cc.SRC_ALPHA;
- blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA;
+ blendFunc.src = cc.Macro.SRC_ALPHA;
+ blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA;
}
};
diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js
index ab82021e97..ddc01ea42b 100644
--- a/cocos2d/core/textures/CCTextureAtlas.js
+++ b/cocos2d/core/textures/CCTextureAtlas.js
@@ -179,7 +179,7 @@ var TextureAtlas = Class.extend(/** @lends cc.TextureAtlas# */{ //WebGL only
return;
var locIndices = this._indices, locCapacity = this._capacity;
for (var i = 0; i < locCapacity; i++) {
- if (cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP) {
+ if (cc.Macro.TEXTURE_ATLAS_USE_TRIANGLE_STRIP) {
locIndices[i * 6 + 0] = i * 4 + 0;
locIndices[i * 6 + 1] = i * 4 + 0;
locIndices[i * 6 + 2] = i * 4 + 2;
@@ -669,7 +669,7 @@ if (cc._renderType === game.RENDER_TYPE_WEBGL) {
//vertices
//gl.bindBuffer(gl.ARRAY_BUFFER, _t._buffersVBO[0]);
// XXX: update is done in draw... perhaps it should be done in a timer
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadsWebBuffer);
if (_t.dirty){
@@ -677,13 +677,13 @@ if (cc._renderType === game.RENDER_TYPE_WEBGL) {
_t.dirty = false;
}
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]);
- if (cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP)
+ if (cc.Macro.TEXTURE_ATLAS_USE_TRIANGLE_STRIP)
gl.drawElements(gl.TRIANGLE_STRIP, n * 6, gl.UNSIGNED_SHORT, start * 6 * _t._indices.BYTES_PER_ELEMENT);
else
gl.drawElements(gl.TRIANGLES, n * 6, gl.UNSIGNED_SHORT, start * 6 * _t._indices.BYTES_PER_ELEMENT);
diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js
index 5947268eee..0573eb8264 100644
--- a/cocos2d/core/textures/CCTextureCache.js
+++ b/cocos2d/core/textures/CCTextureCache.js
@@ -349,7 +349,7 @@ game.once(game.EVENT_RENDERER_INITED, function () {
tex = locTexs[url] = new Texture2D();
tex.url = url;
}
- premultiplied = cc.AUTO_PREMULTIPLIED_ALPHA_FOR_PNG && (cc.path.extname(url) === ".png");
+ premultiplied = cc.Macro.AUTO_PREMULTIPLIED_ALPHA_FOR_PNG && (cc.path.extname(url) === ".png");
tex.handleLoadedTexture(premultiplied);
};
diff --git a/cocos2d/core/utils/Async.js b/cocos2d/core/utils/Async.js
deleted file mode 100644
index b9b0838cf2..0000000000
--- a/cocos2d/core/utils/Async.js
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
- Copyright (c) 2013-2016 Chukong Technologies Inc.
-
- http://www.cocos.com
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated engine source code (the "Software"), a limited,
- worldwide, royalty-free, non-assignable, revocable and non-exclusive license
- to use Cocos Creator solely to develop games on your target platforms. You shall
- not use Cocos Creator software for developing other software or tools that's
- used for developing games. You are not granted to publish, distribute,
- sublicense, and/or sell copies of Cocos Creator.
-
- The software or tools in this License Agreement are licensed, not sold.
- Chukong Aipu reserves all rights not expressly granted to you.
-
- 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.
- ****************************************************************************/
-
-/**
- * Async Pool class, a helper of cc.async
- * @class AsyncPool
- * @constructor
- * @param {Object|Array} srcObj
- * @param {Number} limit the limit of parallel number
- * @param {Function} iterator
- * @param {Function} onEnd
- * @param {Object} target
- */
-cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){
- var self = this;
- self._srcObj = srcObj;
- self._limit = limit;
- self._pool = [];
- self._iterator = iterator;
- self._iteratorTarget = target;
- self._onEnd = onEnd;
- self._onEndTarget = target;
- self._errors = [];
- self._results = 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, res){
- self.finishedSize++;
- self._workingSize--;
-
- if (err) {
- self._errors.push(err);
- }
- self._results[this.index] = res;
-
- if (self.finishedSize === self.size) {
- if (self._onEnd)
- self._onEnd.call(self._onEndTarget, self._errors.length > 0 ? self._errors : null, 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();
- }
-};
-
-/**
- * @class async
- */
-cc.async = /** @lends cc.async# */{
- /**
- * Do tasks series.
- * @method series
- * @param {Array|Object} tasks
- * @param {Function} [cb] - callback
- * @param {Object} [target]
- * @return {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.
- * @method parallel
- * @param {Array|Object} tasks
- * @param {Function} cb - callback
- * @param {Object} [target]
- * @return {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.
- * @method waterfall
- * @param {Array|Object} tasks
- * @param {Function} cb - callback
- * @param {Object} [target]
- * @return {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.
- * @method map
- * @param {Array|Object} tasks
- * @param {Function|Object} iterator
- * @param {Function} [callback]
- * @param {Object} [target]
- * @return {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.
- * @method mapLimit
- * @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;
- }
-};
\ No newline at end of file
diff --git a/cocos2d/core/utils/CCProfiler.js b/cocos2d/core/utils/CCProfiler.js
index 26af34020a..9ecb57fbc5 100644
--- a/cocos2d/core/utils/CCProfiler.js
+++ b/cocos2d/core/utils/CCProfiler.js
@@ -45,7 +45,7 @@ cc.profiler = (function () {
var createStatsLabel = function () {
var fontSize = 0;
var w = cc.winSize.width, h = cc.winSize.height;
- var locStatsPosition = cc.DIRECTOR_STATS_POSITION;
+ var locStatsPosition = cc.Macro.DIRECTOR_STATS_POSITION;
if (w > h)
fontSize = 0 | (h / 320 * 20);
else
@@ -110,7 +110,7 @@ cc.profiler = (function () {
_frames++;
_accumDt += cc.director.getDeltaTime();
- if (_accumDt > cc.DIRECTOR_FPS_INTERVAL) {
+ if (_accumDt > cc.Macro.DIRECTOR_FPS_INTERVAL) {
_frameRate = _frames / _accumDt;
_frames = 0;
_accumDt = 0;
@@ -151,7 +151,7 @@ cc.profiler = (function () {
setProfileDuration: function (duration) {
if (!isNaN(duration) && duration > 0) {
- _levelDetCycle = duration / cc.DIRECTOR_FPS_INTERVAL;
+ _levelDetCycle = duration / cc.Macro.DIRECTOR_FPS_INTERVAL;
}
},
diff --git a/cocos2d/core/utils/index.js b/cocos2d/core/utils/index.js
index 7e5d7cf47d..6ba602bde0 100644
--- a/cocos2d/core/utils/index.js
+++ b/cocos2d/core/utils/index.js
@@ -22,7 +22,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-require('./Async');
+
require('./CCPath');
require('./CCProfiler');
require('./find');
diff --git a/cocos2d/core/value-types/CCTypes.js b/cocos2d/core/value-types/CCTypes.js
index f15ea7a001..f0445309c3 100644
--- a/cocos2d/core/value-types/CCTypes.js
+++ b/cocos2d/core/value-types/CCTypes.js
@@ -61,16 +61,16 @@ cc.BlendFunc = function (src1, dst1) {
};
var BlendFactor = cc.Enum({
- ONE: 1, //cc.ONE
- ZERO: 0, //cc.ZERO
- SRC_ALPHA: 0x302, //cc.SRC_ALPHA
- SRC_COLOR: 0x300, //cc.SRC_COLOR
- DST_ALPHA: 0x304, //cc.DST_ALPHA
- DST_COLOR: 0x306, //cc.DST_COLOR
- ONE_MINUS_SRC_ALPHA: 0x303, //cc.ONE_MINUS_SRC_ALPHA
- ONE_MINUS_SRC_COLOR: 0x301, //cc.ONE_MINUS_SRC_COLOR
- ONE_MINUS_DST_ALPHA: 0x305, //cc.ONE_MINUS_DST_ALPHA
- ONE_MINUS_DST_COLOR: 0x307, //cc.ONE_MINUS_DST_COLOR
+ ONE: 1, //cc.Macro.ONE
+ ZERO: 0, //cc.Macro.ZERO
+ SRC_ALPHA: 0x302, //cc.Macro.SRC_ALPHA
+ SRC_COLOR: 0x300, //cc.Macro.SRC_COLOR
+ DST_ALPHA: 0x304, //cc.Macro.DST_ALPHA
+ DST_COLOR: 0x306, //cc.Macro.DST_COLOR
+ ONE_MINUS_SRC_ALPHA: 0x303, //cc.Macro.ONE_MINUS_SRC_ALPHA
+ ONE_MINUS_SRC_COLOR: 0x301, //cc.Macro.ONE_MINUS_SRC_COLOR
+ ONE_MINUS_DST_ALPHA: 0x305, //cc.Macro.ONE_MINUS_DST_ALPHA
+ ONE_MINUS_DST_COLOR: 0x307, //cc.Macro.ONE_MINUS_DST_COLOR
});
//var BlendFactor = cc;
diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js
index dc6a59182d..9260ee5100 100644
--- a/cocos2d/effects/CCGrid.js
+++ b/cocos2d/effects/CCGrid.js
@@ -228,7 +228,7 @@ cc.GridBase = cc._Class.extend(/** @lends cc.GridBase# */{
if (!this._grabber)
return false;
this._grabber.grab(this._texture);
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
+ this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURE);
this.calculateVertexPoints();
return true;
},
@@ -449,7 +449,7 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{
blit:function (target) {
var n = this._gridSize.width * this._gridSize.height;
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION | cc.Macro.VERTEX_ATTRIB_FLAG_TEX_COORDS);
this._shaderProgram.use();
//this._shaderProgram.setUniformsForBuiltins();
this._shaderProgram._setUniformForMVPMatrixWithMat4(target._renderCmd._stackMatrix);
@@ -462,13 +462,13 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{
gl.bindBuffer(gl.ARRAY_BUFFER, this._verticesBuffer);
if (locDirty)
gl.bufferData(gl.ARRAY_BUFFER, this._vertices, gl.DYNAMIC_DRAW);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 0, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 0, 0);
// texCoords
gl.bindBuffer(gl.ARRAY_BUFFER, this._texCoordinateBuffer);
if (locDirty)
gl.bufferData(gl.ARRAY_BUFFER, this._texCoordinates, gl.DYNAMIC_DRAW);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
if (locDirty)
@@ -715,19 +715,19 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{
// Attributes
//
var gl = cc._renderContext, locDirty = this._dirty;
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION | cc.Macro.VERTEX_ATTRIB_FLAG_TEX_COORDS);
// position
gl.bindBuffer(gl.ARRAY_BUFFER, this._verticesBuffer);
if (locDirty)
gl.bufferData(gl.ARRAY_BUFFER, this._vertices, gl.DYNAMIC_DRAW);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 0, this._vertices);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 0, this._vertices);
// texCoords
gl.bindBuffer(gl.ARRAY_BUFFER, this._texCoordinateBuffer);
if (locDirty)
gl.bufferData(gl.ARRAY_BUFFER, this._texCoordinates, gl.DYNAMIC_DRAW);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, this._texCoordinates);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, this._texCoordinates);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
if (locDirty)
diff --git a/cocos2d/kazmath/utility.js b/cocos2d/kazmath/utility.js
index 9cd3fb4c71..2ffe652038 100644
--- a/cocos2d/kazmath/utility.js
+++ b/cocos2d/kazmath/utility.js
@@ -35,9 +35,9 @@
*/
cc.math = cc.math || {};
-//cc.kmPIOver180 = 0.017453; please use cc.RAD
+//cc.kmPIOver180 = 0.017453; please use cc.Macro.RAD
-//cc.kmPIUnder180 = 57.295779; please use cc.DEG
+//cc.kmPIUnder180 = 57.295779; please use cc.Macro.DEG
cc.math.EPSILON = 1.0 / 64.0; //cc.kmEpsilon
diff --git a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js
index b60438c28e..3e0b3bccc7 100644
--- a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js
+++ b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js
@@ -39,7 +39,7 @@
proto.rendering = function(ctx){
cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this, ctx);
- if (cc.LABELATLAS_DEBUG_DRAW) {
+ if (cc.Macro.LABELATLAS_DEBUG_DRAW) {
var node = this._node;
var s = node.getContentSize();
var locRect = node.getBoundingBoxToWorld();
@@ -82,7 +82,7 @@
cr++;
var left, right, top, bottom;
- if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) {
+ if (cc.Macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) {
// Issue #938. Don't use texStepX & texStepY
left = (2 * row * itemWidth + 1) / (2 * textureWide);
right = left + (itemWidth * 2 - 2) / (2 * textureWide);
diff --git a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js
index 48e292e771..37031c5b6a 100644
--- a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js
+++ b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js
@@ -71,7 +71,7 @@
var node = this._node;
//LabelBMFont - Debug draw
- if (cc.LABELBMFONT_DEBUG_DRAW) {
+ if (cc.Macro.LABELBMFONT_DEBUG_DRAW) {
var size = node.getContentSize();
var pos = cc.p(0 | ( -this._anchorPointInPoints.x), 0 | ( -this._anchorPointInPoints.y));
var vertices = [cc.p(pos.x, pos.y), cc.p(pos.x + size.width, pos.y), cc.p(pos.x + size.width, pos.y + size.height), cc.p(pos.x, pos.y + size.height)];
diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js
index 64c7579048..7a6ee83580 100644
--- a/cocos2d/menus/CCMenuItem.js
+++ b/cocos2d/menus/CCMenuItem.js
@@ -24,7 +24,7 @@
THE SOFTWARE.
****************************************************************************/
-cc._globalFontSize = cc.ITEM_SIZE;
+cc._globalFontSize = cc.Macro.ITEM_SIZE;
cc._globalFontName = "Arial";
cc._globalFontNameRelease = false;
@@ -362,14 +362,14 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{
if (this._enabled) {
cc.MenuItem.prototype.selected.call(this);
- var action = this.getActionByTag(cc.ZOOM_ACTION_TAG);
+ var action = this.getActionByTag(cc.Macro.ZOOM_ACTION_TAG);
if (action)
this.stopAction(action);
else
this._originalScale = this.scale;
var zoomAction = cc.scaleTo(0.1, this._originalScale * 1.2);
- zoomAction.setTag(cc.ZOOM_ACTION_TAG);
+ zoomAction.setTag(cc.Macro.ZOOM_ACTION_TAG);
this.runAction(zoomAction);
}
},
@@ -380,9 +380,9 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{
unselected: function () {
if (this._enabled) {
cc.MenuItem.prototype.unselected.call(this);
- this.stopActionByTag(cc.ZOOM_ACTION_TAG);
+ this.stopActionByTag(cc.Macro.ZOOM_ACTION_TAG);
var zoomAction = cc.scaleTo(0.1, this._originalScale);
- zoomAction.setTag(cc.ZOOM_ACTION_TAG);
+ zoomAction.setTag(cc.Macro.ZOOM_ACTION_TAG);
this.runAction(zoomAction);
}
}
@@ -732,7 +732,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{
return;
}
if (normalImage) {
- this.addChild(normalImage, 0, cc.NORMAL_TAG);
+ this.addChild(normalImage, 0, cc.Macro.NORMAL_TAG);
normalImage.anchorX = 0;
normalImage.anchorY = 0;
}
@@ -773,7 +773,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{
return;
if (selectedImage) {
- this.addChild(selectedImage, 0, cc.SELECTED_TAG);
+ this.addChild(selectedImage, 0, cc.Macro.SELECTED_TAG);
selectedImage.anchorX = 0;
selectedImage.anchorY = 0;
}
@@ -803,7 +803,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{
return;
if (disabledImage) {
- this.addChild(disabledImage, 0, cc.DISABLE_TAG);
+ this.addChild(disabledImage, 0, cc.Macro.DISABLE_TAG);
disabledImage.anchorX = 0;
disabledImage.anchorY = 0;
}
@@ -1180,12 +1180,12 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{
setSelectedIndex: function (SelectedIndex) {
if (SelectedIndex !== this._selectedIndex) {
this._selectedIndex = SelectedIndex;
- var currItem = this.getChildByTag(cc.CURRENT_ITEM);
+ var currItem = this.getChildByTag(cc.Macro.CURRENT_ITEM);
if (currItem)
currItem.removeFromParent(false);
var item = this.subItems[this._selectedIndex];
- this.addChild(item, 0, cc.CURRENT_ITEM);
+ this.addChild(item, 0, cc.Macro.CURRENT_ITEM);
var w = item.width, h = item.height;
this.width = w;
this.height = h;
@@ -1235,7 +1235,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{
if (args[i])
locSubItems.push(args[i]);
}
- this._selectedIndex = cc.UINT_MAX;
+ this._selectedIndex = cc.Macro.UINT_MAX;
this.setSelectedIndex(0);
this.setCascadeColorEnabled(true);
diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js
index 0f850fe210..66d533c48d 100644
--- a/cocos2d/motion-streak/CCMotionStreak.js
+++ b/cocos2d/motion-streak/CCMotionStreak.js
@@ -84,7 +84,7 @@ cc.MotionStreak = _ccsg.Node.extend(/** @lends cc.MotionStreak# */{
ctor: function (fade, minSeg, stroke, color, texture) {
_ccsg.Node.prototype.ctor.call(this);
this._positionR = cc.p(0, 0);
- this._blendFunc = new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA);
+ this._blendFunc = new cc.BlendFunc(cc.Macro.SRC_ALPHA, cc.Macro.ONE_MINUS_SRC_ALPHA);
this.fastMode = false;
this.startingPositionInitialized = false;
diff --git a/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js b/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js
index 621aae5b47..b47388541a 100644
--- a/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js
+++ b/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js
@@ -25,7 +25,7 @@
cc.MotionStreak.WebGLRenderCmd = function(renderableObject){
_ccsg.Node.WebGLRenderCmd.call(this, renderableObject);
this._needDraw = true;
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
+ this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR);
};
cc.MotionStreak.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype);
@@ -40,7 +40,7 @@ cc.MotionStreak.WebGLRenderCmd.prototype.rendering = function(ctx){
ctx = ctx || cc._renderContext;
this._shaderProgram.use();
this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst);
cc.glBindTexture2D(node.texture);
@@ -48,17 +48,17 @@ cc.MotionStreak.WebGLRenderCmd.prototype.rendering = function(ctx){
//position
ctx.bindBuffer(ctx.ARRAY_BUFFER, node._verticesBuffer);
ctx.bufferData(ctx.ARRAY_BUFFER, node._vertices, ctx.DYNAMIC_DRAW);
- ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0);
+ ctx.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0);
//texcoords
ctx.bindBuffer(ctx.ARRAY_BUFFER, node._texCoordsBuffer);
ctx.bufferData(ctx.ARRAY_BUFFER, node._texCoords, ctx.DYNAMIC_DRAW);
- ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0);
+ ctx.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0);
//colors
ctx.bindBuffer(ctx.ARRAY_BUFFER, node._colorPointerBuffer);
ctx.bufferData(ctx.ARRAY_BUFFER, node._colorPointer, ctx.DYNAMIC_DRAW);
- ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0);
+ ctx.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0);
ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, node._nuPoints * 2);
cc.g_NumberOfDraws++;
diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js
index c9f6a58248..efa4bcd0dd 100644
--- a/cocos2d/node-grid/CCNodeGrid.js
+++ b/cocos2d/node-grid/CCNodeGrid.js
@@ -109,7 +109,7 @@ cc.NodeGrid = _ccsg.Node.extend({
apx = app.x, apy = app.y,
translate = (apx !== 0.0 || apy !== 0.0);
if (translate) {
- if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) {
+ if(!cc.Macro.SPRITEBATCHNODE_RENDER_SUBPIXEL) {
apx = 0 | apx;
apy = 0 | apy;
}
diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js
index 1ae02c35a2..daff2faf5b 100644
--- a/cocos2d/particle/CCParticleBatchNode.js
+++ b/cocos2d/particle/CCParticleBatchNode.js
@@ -93,7 +93,7 @@ cc.ParticleBatchNode = _ccsg.Node.extend(/** @lends cc.ParticleBatchNode# */{
*/
ctor:function (fileImage, capacity) {
_ccsg.Node.prototype.ctor.call(this);
- this._blendFunc = {src:cc.BLEND_SRC, dst:cc.BLEND_DST};
+ this._blendFunc = {src:cc.Macro.BLEND_SRC, dst:cc.Macro.BLEND_DST};
if (cc.js.isString(fileImage)) {
this.init(fileImage, capacity);
} else if (fileImage instanceof cc.Texture2D) {
@@ -350,9 +350,9 @@ cc.ParticleBatchNode = _ccsg.Node.extend(/** @lends cc.ParticleBatchNode# */{
// If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it
var locBlendFunc = this._blendFunc;
- if (texture && !texture.hasPremultipliedAlpha() && ( locBlendFunc.src === cc.BLEND_SRC && locBlendFunc.dst === cc.BLEND_DST )) {
- locBlendFunc.src = cc.SRC_ALPHA;
- locBlendFunc.dst = cc.ONE_MINUS_SRC_ALPHA;
+ if (texture && !texture.hasPremultipliedAlpha() && ( locBlendFunc.src === cc.Macro.BLEND_SRC && locBlendFunc.dst === cc.Macro.BLEND_DST )) {
+ locBlendFunc.src = cc.Macro.SRC_ALPHA;
+ locBlendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA;
}
},
@@ -485,8 +485,8 @@ cc.ParticleBatchNode = _ccsg.Node.extend(/** @lends cc.ParticleBatchNode# */{
_updateBlendFunc:function () {
if (!this.textureAtlas.texture.hasPremultipliedAlpha()) {
- this._blendFunc.src = cc.SRC_ALPHA;
- this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA;
+ this._blendFunc.src = cc.Macro.SRC_ALPHA;
+ this._blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA;
}
},
diff --git a/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js
index 93a6ef22be..ba8caa0ab9 100644
--- a/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js
+++ b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js
@@ -46,7 +46,7 @@
};
proto._initWithTexture = function(){
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
+ this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR);
};
proto.visit = function(parentCmd){
diff --git a/cocos2d/particle/CCSGParticleSystem.js b/cocos2d/particle/CCSGParticleSystem.js
index b854f8b820..c05f659798 100644
--- a/cocos2d/particle/CCSGParticleSystem.js
+++ b/cocos2d/particle/CCSGParticleSystem.js
@@ -290,7 +290,7 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({
this.emitterMode = _ccsg.ParticleSystem.Mode.GRAVITY;
this.modeA = new _ccsg.ParticleSystem.ModeA();
this.modeB = new _ccsg.ParticleSystem.ModeB();
- this._blendFunc = {src:cc.BLEND_SRC, dst:cc.BLEND_DST};
+ this._blendFunc = {src:cc.Macro.BLEND_SRC, dst:cc.Macro.BLEND_DST};
this._particles = [];
this._sourcePosition = cc.p(0, 0);
@@ -1128,7 +1128,8 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({
* dest blend function = GL_ONE;
*/
isBlendAdditive:function () {
- return (( this._blendFunc.src === cc.SRC_ALPHA && this._blendFunc.dst === cc.ONE) || (this._blendFunc.src === cc.ONE && this._blendFunc.dst === cc.ONE));
+ return (( this._blendFunc.src === cc.Macro.SRC_ALPHA && this._blendFunc.dst === cc.Macro.ONE) ||
+ (this._blendFunc.src === cc.Macro.ONE && this._blendFunc.dst === cc.Macro.ONE));
},
/**
@@ -1140,8 +1141,8 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({
setBlendAdditive:function (isBlendAdditive) {
var locBlendFunc = this._blendFunc;
if (isBlendAdditive) {
- locBlendFunc.src = cc.SRC_ALPHA;
- locBlendFunc.dst = cc.ONE;
+ locBlendFunc.src = cc.Macro.SRC_ALPHA;
+ locBlendFunc.dst = cc.Macro.ONE;
} else {
this._renderCmd._setBlendAdditive();
}
@@ -1388,13 +1389,13 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({
var imageFormat = cc.getImageFormatByData(buffer);
- if(imageFormat !== cc.FMT_TIFF && imageFormat !== cc.FMT_PNG){
+ if(imageFormat !== cc.ImageFormat.TIFF && imageFormat !== cc.ImageFormat.PNG){
cc.log("_ccsg.ParticleSystem: unknown image format with Data");
return false;
}
var canvasObj = document.createElement("canvas");
- if(imageFormat === cc.FMT_PNG){
+ if(imageFormat === cc.ImageFormat.PNG){
var myPngObj = new cc.PNGReader(buffer);
myPngObj.render(canvasObj);
} else {
@@ -1444,8 +1445,8 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({
this._isActive = true;
// default blend function
- this._blendFunc.src = cc.BLEND_SRC;
- this._blendFunc.dst = cc.BLEND_DST;
+ this._blendFunc.src = cc.Macro.BLEND_SRC;
+ this._blendFunc.dst = cc.Macro.BLEND_DST;
// default movement type;
this.positionType = _ccsg.ParticleSystem.Type.FREE;
@@ -1830,12 +1831,12 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({
if (locTexture && locTexture instanceof cc.Texture2D) {
this._opacityModifyRGB = false;
var locBlendFunc = this._blendFunc;
- if (locBlendFunc.src === cc.BLEND_SRC && locBlendFunc.dst === cc.BLEND_DST) {
+ if (locBlendFunc.src === cc.Macro.BLEND_SRC && locBlendFunc.dst === cc.Macro.BLEND_DST) {
if (locTexture.hasPremultipliedAlpha()) {
this._opacityModifyRGB = true;
} else {
- locBlendFunc.src = cc.SRC_ALPHA;
- locBlendFunc.dst = cc.ONE_MINUS_SRC_ALPHA;
+ locBlendFunc.src = cc.Macro.SRC_ALPHA;
+ locBlendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA;
}
}
}
diff --git a/cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js b/cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js
index c7732cd793..b206c2a3ff 100644
--- a/cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js
+++ b/cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js
@@ -182,8 +182,8 @@
proto._setBlendAdditive = function(){
var locBlendFunc = this._node._blendFunc;
- locBlendFunc.src = cc.BLEND_SRC;
- locBlendFunc.dst = cc.BLEND_DST;
+ locBlendFunc.src = cc.Macro.BLEND_SRC;
+ locBlendFunc.dst = cc.Macro.BLEND_DST;
};
proto._initWithTotalParticles = function(totalParticles){};
diff --git a/cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js b/cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js
index 945f4cb6e4..48c7834c18 100644
--- a/cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js
+++ b/cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js
@@ -195,12 +195,12 @@
//
// Using VBO without VAO
//
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
gl.bindBuffer(gl.ARRAY_BUFFER, this._buffersVBO[0]);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
gl.drawElements(gl.TRIANGLES, node._particleIdx * 6, gl.UNSIGNED_SHORT, 0);
@@ -219,7 +219,7 @@
}
var left, bottom, right, top;
- if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) {
+ if (cc.Macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) {
left = (pointRect.x * 2 + 1) / (wide * 2);
bottom = (pointRect.y * 2 + 1) / (high * 2);
right = left + (pointRect.width * 2 - 2) / (wide * 2);
@@ -365,11 +365,11 @@
proto._setBlendAdditive = function(){
var locBlendFunc = this._node._blendFunc;
if (this._texture && !this._texture.hasPremultipliedAlpha()) {
- locBlendFunc.src = cc.SRC_ALPHA;
- locBlendFunc.dst = cc.ONE_MINUS_SRC_ALPHA;
+ locBlendFunc.src = cc.Macro.SRC_ALPHA;
+ locBlendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA;
} else {
- locBlendFunc.src = cc.BLEND_SRC;
- locBlendFunc.dst = cc.BLEND_DST;
+ locBlendFunc.src = cc.Macro.BLEND_SRC;
+ locBlendFunc.dst = cc.Macro.BLEND_DST;
}
};
@@ -381,7 +381,7 @@
this.initIndices(totalParticles);
this._setupVBO();
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
+ this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR);
};
proto._updateDeltaColor = function (selParticle, dt) {
diff --git a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js
index 4c829203c2..47406e3808 100644
--- a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js
+++ b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js
@@ -51,7 +51,7 @@
var blendFunc = node._sprite._blendFunc;
cc.glBlendFunc(blendFunc.src, blendFunc.dst);
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
cc.glBindTexture2D(node._sprite.texture);
@@ -61,9 +61,9 @@
this._vertexDataDirty = false;
}
var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
- context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0);
- context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, locVertexDataLen, 8);
- context.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, context.FLOAT, false, locVertexDataLen, 12);
+ context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0);
+ context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, locVertexDataLen, 8);
+ context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, context.FLOAT, false, locVertexDataLen, 12);
if (node._type === cc.ProgressTimer.Type.RADIAL)
context.drawArrays(context.TRIANGLE_FAN, 0, this._vertexDataCount);
@@ -169,7 +169,7 @@
this._vertexDataCount = 0;
//shader program
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
+ this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR);
};
proto._updateProgress = function(){
@@ -316,7 +316,7 @@
var i, locMidPoint = node._midPoint;
var alpha = node._percentage / 100;
- var angle = 2 * (cc.PI) * ( node._reverseDirection ? alpha : 1.0 - alpha);
+ var angle = 2 * (Math.PI) * ( node._reverseDirection ? alpha : 1.0 - alpha);
// We find the vector to do a hit detection based on the percentage
// We know the first vector is the one @ 12 o'clock (top,mid) so we rotate
@@ -342,7 +342,7 @@
// intersection point
// We loop through five points since the top is split in half
- var min_t = cc.FLT_MAX;
+ var min_t = cc.Macro.FLT_MAX;
var locProTextCoordsCount = cc.ProgressTimer.TEXTURE_COORDS_COUNT;
for (i = 0; i <= locProTextCoordsCount; ++i) {
var pIndex = (i + (locProTextCoordsCount - 1)) % locProTextCoordsCount;
diff --git a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js
index 5a5f1ca9ea..7172765279 100644
--- a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js
+++ b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js
@@ -59,7 +59,7 @@
texture.handleLoadedTexture();
var locSprite = node.sprite = new _ccsg.Sprite(texture);
- locSprite.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA);
+ locSprite.setBlendFunc(cc.Macro.ONE, cc.Macro.ONE_MINUS_SRC_ALPHA);
// Disabled by default.
node.autoDraw = false;
// add sprite for backward compatibility
diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js
index 70eae0eb69..0cd2f84931 100644
--- a/cocos2d/shaders/CCGLProgram.js
+++ b/cocos2d/shaders/CCGLProgram.js
@@ -261,27 +261,27 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{
/**
* It will create 4 uniforms:
- * cc.UNIFORM_PMATRIX
- * cc.UNIFORM_MVMATRIX
- * cc.UNIFORM_MVPMATRIX
- * cc.UNIFORM_SAMPLER
+ * cc.Macro.UNIFORM_PMATRIX
+ * cc.Macro.UNIFORM_MVMATRIX
+ * cc.Macro.UNIFORM_MVPMATRIX
+ * cc.Macro.UNIFORM_SAMPLER
*/
updateUniforms: function () {
- this._uniforms[cc.UNIFORM_PMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_PMATRIX_S);
- this._uniforms[cc.UNIFORM_MVMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVMATRIX_S);
- this._uniforms[cc.UNIFORM_MVPMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVPMATRIX_S);
- this._uniforms[cc.UNIFORM_TIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_TIME_S);
- this._uniforms[cc.UNIFORM_SINTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SINTIME_S);
- this._uniforms[cc.UNIFORM_COSTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_COSTIME_S);
+ this._uniforms[cc.Macro.UNIFORM_PMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_PMATRIX_S);
+ this._uniforms[cc.Macro.UNIFORM_MVMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_MVMATRIX_S);
+ this._uniforms[cc.Macro.UNIFORM_MVPMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_MVPMATRIX_S);
+ this._uniforms[cc.Macro.UNIFORM_TIME] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_TIME_S);
+ this._uniforms[cc.Macro.UNIFORM_SINTIME] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_SINTIME_S);
+ this._uniforms[cc.Macro.UNIFORM_COSTIME] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_COSTIME_S);
- this._usesTime = (this._uniforms[cc.UNIFORM_TIME] != null || this._uniforms[cc.UNIFORM_SINTIME] != null || this._uniforms[cc.UNIFORM_COSTIME] != null);
+ this._usesTime = (this._uniforms[cc.Macro.UNIFORM_TIME] != null || this._uniforms[cc.Macro.UNIFORM_SINTIME] != null || this._uniforms[cc.Macro.UNIFORM_COSTIME] != null);
- this._uniforms[cc.UNIFORM_RANDOM01] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_RANDOM01_S);
- this._uniforms[cc.UNIFORM_SAMPLER] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SAMPLER_S);
+ this._uniforms[cc.Macro.UNIFORM_RANDOM01] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_RANDOM01_S);
+ this._uniforms[cc.Macro.UNIFORM_SAMPLER] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_SAMPLER_S);
this.use();
// Since sample most probably won't change, set it to 0 now.
- this.setUniformLocationWith1i(this._uniforms[cc.UNIFORM_SAMPLER], 0);
+ this.setUniformLocationWith1i(this._uniforms[cc.Macro.UNIFORM_SAMPLER], 0);
},
/**
@@ -303,7 +303,7 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{
* @returns {WebGLUniformLocation}
*/
getUniformMVPMatrix: function () {
- return this._uniforms[cc.UNIFORM_MVPMATRIX];
+ return this._uniforms[cc.Macro.UNIFORM_MVPMATRIX];
},
/**
@@ -311,7 +311,7 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{
* @returns {WebGLUniformLocation}
*/
getUniformSampler: function () {
- return this._uniforms[cc.UNIFORM_SAMPLER];
+ return this._uniforms[cc.Macro.UNIFORM_SAMPLER];
},
/**
@@ -552,9 +552,9 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{
cc.kmMat4Multiply(matrixMVP, matrixP, matrixMV);
- this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], matrixP.mat, 1);
- this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], matrixMV.mat, 1);
- this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], matrixMVP.mat, 1);
+ this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_PMATRIX], matrixP.mat, 1);
+ this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVMATRIX], matrixMV.mat, 1);
+ this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVPMATRIX], matrixMVP.mat, 1);
if (this._usesTime) {
var director = cc.director;
@@ -563,13 +563,13 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{
// Getting Mach time per frame per shader using time could be extremely expensive.
var time = director.getTotalFrames() * director.getAnimationInterval();
- this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME], time / 10.0, time, time * 2, time * 4);
- this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME], time / 8.0, time / 4.0, time / 2.0, Math.sin(time));
- this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time));
+ this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_TIME], time / 10.0, time, time * 2, time * 4);
+ this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_SINTIME], time / 8.0, time / 4.0, time / 2.0, Math.sin(time));
+ this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time));
}
- if (this._uniforms[cc.UNIFORM_RANDOM01] !== -1)
- this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random());
+ if (this._uniforms[cc.Macro.UNIFORM_RANDOM01] !== -1)
+ this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random());
},
_setUniformsForBuiltinsForRenderer: function (node) {
@@ -585,9 +585,9 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{
cc.kmMat4Multiply(matrixMVP, matrixP, node._renderCmd._stackMatrix);
- this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], matrixP.mat, 1);
- this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], node._renderCmd._stackMatrix.mat, 1);
- this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], matrixMVP.mat, 1);
+ this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_PMATRIX], matrixP.mat, 1);
+ this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVMATRIX], node._renderCmd._stackMatrix.mat, 1);
+ this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVPMATRIX], matrixMVP.mat, 1);
if (this._usesTime) {
var director = cc.director;
@@ -596,38 +596,38 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{
// Getting Mach time per frame per shader using time could be extremely expensive.
var time = director.getTotalFrames() * director.getAnimationInterval();
- this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME], time / 10.0, time, time * 2, time * 4);
- this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME], time / 8.0, time / 4.0, time / 2.0, Math.sin(time));
- this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time));
+ this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_TIME], time / 10.0, time, time * 2, time * 4);
+ this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_SINTIME], time / 8.0, time / 4.0, time / 2.0, Math.sin(time));
+ this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time));
}
- if (this._uniforms[cc.UNIFORM_RANDOM01] !== -1)
- this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random());
+ if (this._uniforms[cc.Macro.UNIFORM_RANDOM01] !== -1)
+ this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random());
},
/**
* will update the MVP matrix on the MVP uniform if it is different than the previous call for this same shader program.
*/
setUniformForModelViewProjectionMatrix: function () {
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], false,
+ this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVPMATRIX], false,
cc.getMat4MultiplyValue(cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top));
},
setUniformForModelViewProjectionMatrixWithMat4: function (swapMat4) {
cc.kmMat4Multiply(swapMat4, cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top);
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], false, swapMat4.mat);
+ this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVPMATRIX], false, swapMat4.mat);
},
setUniformForModelViewAndProjectionMatrixWithMat4: function () {
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], false, cc.modelview_matrix_stack.top.mat);
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], false, cc.projection_matrix_stack.top.mat);
+ this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVMATRIX], false, cc.modelview_matrix_stack.top.mat);
+ this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_PMATRIX], false, cc.projection_matrix_stack.top.mat);
},
_setUniformForMVPMatrixWithMat4: function(modelViewMatrix){
if(!modelViewMatrix)
throw new Error("modelView matrix is undefined.");
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], false, modelViewMatrix.mat);
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], false, cc.projection_matrix_stack.top.mat);
+ this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVMATRIX], false, modelViewMatrix.mat);
+ this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_PMATRIX], false, cc.projection_matrix_stack.top.mat);
},
/**
@@ -753,7 +753,7 @@ cc.GLProgram._isHighpSupported = function(){
* @param {_ccsg.Node} node
* @param {cc.GLProgram} program The shader program which fetches from CCShaderCache.
* @example
- * cc.setGLProgram(node, cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR));
+ * cc.setGLProgram(node, cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR));
*/
cc.setProgram = function (node, program) {
node.shaderProgram = program;
diff --git a/cocos2d/shaders/CCGLStateCache.js b/cocos2d/shaders/CCGLStateCache.js
index 4523cc468d..70b1387591 100644
--- a/cocos2d/shaders/CCGLStateCache.js
+++ b/cocos2d/shaders/CCGLStateCache.js
@@ -29,7 +29,9 @@ cc._vertexAttribPosition = false;
cc._vertexAttribColor = false;
cc._vertexAttribTexCoords = false;
-if (cc.ENABLE_GL_STATE_CACHE) {
+var ENABLE_GL_STATE_CACHE = cc.Macro.ENABLE_GL_STATE_CACHE;
+
+if (ENABLE_GL_STATE_CACHE) {
cc.MAX_ACTIVETEXTURE = 16;
cc._currentShaderProgram = -1;
@@ -37,7 +39,7 @@ if (cc.ENABLE_GL_STATE_CACHE) {
cc._blendingSource = -1;
cc._blendingDest = -1;
cc._GLServerState = 0;
- if(cc.TEXTURE_ATLAS_USE_VAO)
+ if(cc.Macro.TEXTURE_ATLAS_USE_VAO)
cc._uVAO = 0;
}
@@ -45,7 +47,7 @@ if (cc.ENABLE_GL_STATE_CACHE) {
/**
* Invalidates the GL state cache.
- * If CC_ENABLE_GL_STATE_CACHE it will reset the GL state cache.
+ * If cc.Macro.ENABLE_GL_STATE_CACHE it will reset the GL state cache.
* @function
*/
cc.glInvalidateStateCache = function () {
@@ -54,7 +56,7 @@ cc.glInvalidateStateCache = function () {
cc._vertexAttribPosition = false;
cc._vertexAttribColor = false;
cc._vertexAttribTexCoords = false;
- if (cc.ENABLE_GL_STATE_CACHE) {
+ if (ENABLE_GL_STATE_CACHE) {
cc._currentShaderProgram = -1;
for (var i = 0; i < cc.MAX_ACTIVETEXTURE; i++) {
cc._currentBoundTexture[i] = -1;
@@ -67,7 +69,7 @@ cc.glInvalidateStateCache = function () {
/**
* Uses the GL program in case program is different than the current one.
- * If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly.
+ * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly.
* @function
* @param {WebGLProgram} program
*/
@@ -78,7 +80,7 @@ cc.glUseProgram = function (program) {
}
};
-if(!cc.ENABLE_GL_STATE_CACHE){
+if(!ENABLE_GL_STATE_CACHE){
cc.glUseProgram = function (program) {
cc._renderContext.useProgram(program);
}
@@ -86,12 +88,12 @@ if(!cc.ENABLE_GL_STATE_CACHE){
/**
* Deletes the GL program. If it is the one that is being used, it invalidates it.
- * If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glDeleteProgram() directly.
+ * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will the glDeleteProgram() directly.
* @function
* @param {WebGLProgram} program
*/
cc.glDeleteProgram = function (program) {
- if (cc.ENABLE_GL_STATE_CACHE) {
+ if (ENABLE_GL_STATE_CACHE) {
if (program === cc._currentShaderProgram)
cc._currentShaderProgram = -1;
}
@@ -100,7 +102,7 @@ cc.glDeleteProgram = function (program) {
/**
* Uses a blending function in case it not already used.
- * If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly.
+ * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly.
* @function
* @param {Number} sfactor
* @param {Number} dfactor
@@ -150,19 +152,19 @@ cc.glBlendFuncForParticle = function(sfactor, dfactor) {
}
};
-if(!cc.ENABLE_GL_STATE_CACHE){
+if(!ENABLE_GL_STATE_CACHE){
cc.glBlendFunc = cc.setBlending;
};
/**
* Resets the blending mode back to the cached state in case you used glBlendFuncSeparate() or glBlendEquation().
- * If CC_ENABLE_GL_STATE_CACHE is disabled, it will just set the default blending mode using GL_FUNC_ADD.
+ * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will just set the default blending mode using GL_FUNC_ADD.
* @function
*/
cc.glBlendResetToCache = function () {
var ctx = cc._renderContext;
ctx.blendEquation(ctx.FUNC_ADD);
- if (cc.ENABLE_GL_STATE_CACHE)
+ if (ENABLE_GL_STATE_CACHE)
cc.setBlending(cc._blendingSource, cc._blendingDest);
else
cc.setBlending(ctx.BLEND_SRC, ctx.BLEND_DST);
@@ -180,51 +182,51 @@ cc.setProjectionMatrixDirty = function () {
*
* Will enable the vertex attribs that are passed as flags.
* Possible flags:
- * cc.VERTEX_ATTRIB_FLAG_POSITION
- * cc.VERTEX_ATTRIB_FLAG_COLOR
- * cc.VERTEX_ATTRIB_FLAG_TEX_COORDS
+ * cc.Macro.VERTEX_ATTRIB_FLAG_POSITION
+ * cc.Macro.VERTEX_ATTRIB_FLAG_COLOR
+ * cc.Macro.VERTEX_ATTRIB_FLAG_TEX_COORDS
*
* These flags can be ORed. The flags that are not present, will be disabled.
*
cc.TMXTiledMap knows how to parse and render a TMX map.
+ *_ccsg.TMXTiledMap knows how to parse and render a TMX map.
* *It adds support for the TMX tiled map format used by http://www.mapeditor.org
* It supports isometric, hexagonal and orthogonal tiles.
@@ -113,15 +113,15 @@ cc.TMX_ORIENTATION_ISO = 2;
* //example
* 1.
* //create a TMXTiledMap with file name
- * var tmxTiledMap = new cc.TMXTiledMap("res/orthogonal-test1.tmx");
+ * var tmxTiledMap = new _ccsg.TMXTiledMap("res/orthogonal-test1.tmx");
* 2.
* //create a TMXTiledMap with content string and resource path
* var resources = "res/TileMaps";
* var filePath = "res/TileMaps/orthogonal-test1.tmx";
* var xmlStr = cc.loader.getRes(filePath);
- * var tmxTiledMap = new cc.TMXTiledMap(xmlStr, resources);
+ * var tmxTiledMap = new _ccsg.TMXTiledMap(xmlStr, resources);
*/
-_ccsg.TMXTiledMap = _ccsg.Node.extend(/** @lends cc.TMXTiledMap# */{
+_ccsg.TMXTiledMap = _ccsg.Node.extend(/** @lends _ccsg.TMXTiledMap# */{
properties: null,
mapOrientation: null,
objectGroups: null,
diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js
index 0a818196a9..b041faf0f3 100644
--- a/cocos2d/transitions/CCTransition.js
+++ b/cocos2d/transitions/CCTransition.js
@@ -1518,8 +1518,8 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross
this._outScene.visit();
outTexture.end();
- inTexture.sprite.setBlendFunc(cc.ONE, cc.ONE); // inScene will lay on background and will not be used with alpha
- outTexture.sprite.setBlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha
+ inTexture.sprite.setBlendFunc(cc.Macro.ONE, cc.Macro.ONE); // inScene will lay on background and will not be used with alpha
+ outTexture.sprite.setBlendFunc(cc.Macro.SRC_ALPHA, cc.Macro.ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha
// add render textures to the layer
layer.addChild(inTexture);
diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js
index 9f833cdd18..de88174cc3 100644
--- a/extensions/ccui/layouts/UILayout.js
+++ b/extensions/ccui/layouts/UILayout.js
@@ -936,7 +936,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
var index = 0, locChildren = this.getChildren();
var count = locChildren.length, widgetPosition;
- var distance = cc.FLT_MAX, found = 0;
+ var distance = cc.Macro.FLT_MAX, found = 0;
if (direction === ccui.Widget.LEFT || direction === ccui.Widget.RIGHT || direction === ccui.Widget.DOWN || direction === ccui.Widget.UP) {
widgetPosition = this._getWorldCenterPoint(baseWidget);
while (index < count) {
@@ -972,7 +972,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
var index = 0, locChildren = this.getChildren();
var count = locChildren.length;
- var distance = -cc.FLT_MAX, found = 0;
+ var distance = -cc.Macro.FLT_MAX, found = 0;
if (direction === ccui.Widget.LEFT || direction === ccui.Widget.RIGHT || direction === ccui.Widget.DOWN || direction === ccui.Widget.UP) {
var widgetPosition = this._getWorldCenterPoint(baseWidget);
while (index < count) {
@@ -1000,7 +1000,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* @private
*/
_calculateNearestDistance: function(baseWidget){
- var distance = cc.FLT_MAX;
+ var distance = cc.Macro.FLT_MAX;
var widgetPosition = this._getWorldCenterPoint(baseWidget);
var locChildren = this._children;
@@ -1027,7 +1027,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* @private
*/
_calculateFarthestDistance:function(baseWidget){
- var distance = -cc.FLT_MAX;
+ var distance = -cc.Macro.FLT_MAX;
var widgetPosition = this._getWorldCenterPoint(baseWidget);
var locChildren = this._children;
diff --git a/extensions/cocostudio/action/CCActionObject.js b/extensions/cocostudio/action/CCActionObject.js
index d87e8f9e71..a78f0f7b41 100644
--- a/extensions/cocostudio/action/CCActionObject.js
+++ b/extensions/cocostudio/action/CCActionObject.js
@@ -200,7 +200,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{
locActionNodeList[i].playAction(fun);
}
if (this._loop)
- this._scheduler.schedule(this.simulationActionUpdate, this, 0, cc.REPEAT_FOREVER, 0, false, this.__instanceId + "");
+ this._scheduler.schedule(this.simulationActionUpdate, this, 0, cc.Macro.REPEAT_FOREVER, 0, false, this.__instanceId + "");
if(fun !== undefined)
this._callback = fun;
},
diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js
index 8f9525718a..8030a42a5c 100644
--- a/extensions/cocostudio/armature/CCArmature.js
+++ b/extensions/cocostudio/armature/CCArmature.js
@@ -68,7 +68,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
this._armatureIndexDic = {};
this._offsetPoint = cc.p(0, 0);
this._armatureTransformDirty = true;
- this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST};
+ this._blendFunc = {src: cc.Macro.BLEND_SRC, dst: cc.Macro.BLEND_DST};
name && ccs.Armature.prototype.init.call(this, name, parentBone);
},
diff --git a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js
index 67dc48c3eb..9f4e8f6aaa 100644
--- a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js
+++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js
@@ -92,7 +92,7 @@
};
proto.initShaderCache = function(){
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
+ this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR);
};
proto.setShaderProgram = function(shaderProgram){
diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js
index dd3149b8b9..38c5f123a7 100644
--- a/extensions/cocostudio/armature/CCBone.js
+++ b/extensions/cocostudio/armature/CCBone.js
@@ -78,7 +78,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{
this._worldTransform = cc.affineTransformMake(1, 0, 0, 1, 0, 0);
this._boneTransformDirty = true;
- this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
+ this._blendFunc = new cc.BlendFunc(cc.Macro.BLEND_SRC, cc.Macro.BLEND_DST);
this.blendDirty = false;
this._worldInfo = null;
diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js
index 5706d1d595..c7d86e1134 100644
--- a/extensions/cocostudio/armature/animation/CCTween.js
+++ b/extensions/cocostudio/armature/animation/CCTween.js
@@ -212,7 +212,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{
}
if (locCurrentPercent < 1 && locLoopType < ccs.ANIMATION_TYPE_TO_LOOP_BACK)
- locCurrentPercent = Math.sin(locCurrentPercent * cc.PI / 2);
+ locCurrentPercent = Math.sin(locCurrentPercent * Math.PI / 2);
this._currentPercent = locCurrentPercent;
this._loopType = locLoopType;
diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js
index 79c0de812a..5bd84bf0a1 100644
--- a/extensions/cocostudio/armature/datas/CCDatas.js
+++ b/extensions/cocostudio/armature/datas/CCDatas.js
@@ -557,7 +557,7 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{
this.event = "";
this.sound = "";
this.soundEffect = "";
- this.blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
+ this.blendFunc = new cc.BlendFunc(cc.Macro.BLEND_SRC, cc.Macro.BLEND_DST);
this.frameID = 0;
this.isTween = true;
},
diff --git a/extensions/cocostudio/armature/display/CCBatchNode.js b/extensions/cocostudio/armature/display/CCBatchNode.js
index c0ef12b7fe..504678a179 100644
--- a/extensions/cocostudio/armature/display/CCBatchNode.js
+++ b/extensions/cocostudio/armature/display/CCBatchNode.js
@@ -40,7 +40,7 @@ ccs.BatchNode = _ccsg.Node.extend(/** @lends ccs.BatchNode# */{
init:function () {
var ret = _ccsg.Node.prototype.init.call(this);
- this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR));
+ this.setShaderProgram(cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURE_UCOLOR));
return ret;
},
diff --git a/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js b/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js
index a4586fdc41..f804e6a3aa 100644
--- a/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js
+++ b/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js
@@ -65,7 +65,7 @@
var dy = x1 * sr + y2 * cr2 + y;
var locVertexZ = node._vertexZ;
- if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) {
+ if(!cc.Macro.SPRITEBATCHNODE_RENDER_SUBPIXEL) {
ax = 0 | ax;
ay = 0 | ay;
bx = 0 | bx;
@@ -106,25 +106,25 @@
cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst);
//optimize performance for javascript
cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture);
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
+ cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer);
if (this._quadDirty) {
gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW);
this._quadDirty = false;
}
- gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION
- gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR
- gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS
+ gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.Macro.VERTEX_ATTRIB_POSITION
+ gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.Macro.VERTEX_ATTRIB_COLOR
+ gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.Macro.VERTEX_ATTRIB_TEX_COORDS
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
}
cc.g_NumberOfDraws++;
- if (cc.SPRITE_DEBUG_DRAW === 0 && !node._showNode)
+ if (cc.Macro.SPRITE_DEBUG_DRAW === 0 && !node._showNode)
return;
- if (cc.SPRITE_DEBUG_DRAW === 1 || node._showNode) {
+ if (cc.Macro.SPRITE_DEBUG_DRAW === 1 || node._showNode) {
// draw bounding box
var locQuad = this._quad;
var verticesG1 = [
@@ -134,7 +134,7 @@
cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y)
];
cc._drawingUtil.drawPoly(verticesG1, 4, true);
- } else if (cc.SPRITE_DEBUG_DRAW === 2) {
+ } else if (cc.Macro.SPRITE_DEBUG_DRAW === 2) {
// draw texture box
var drawRectG2 = node.getTextureRect();
var offsetPixG2 = node.getOffsetPosition();
diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js
index 77cd0333c9..99c837dde9 100644
--- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js
+++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js
@@ -847,24 +847,24 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{
var blendFunc = frameData.blendFunc;
switch (blendType) {
case ccs.BLEND_TYPE_NORMAL:
- blendFunc.src = cc.BLEND_SRC;
- blendFunc.dst = cc.BLEND_DST;
+ blendFunc.src = cc.Macro.BLEND_SRC;
+ blendFunc.dst = cc.Macro.BLEND_DST;
break;
case ccs.BLEND_TYPE_ADD:
- blendFunc.src = cc.SRC_ALPHA;
- blendFunc.dst = cc.ONE;
+ blendFunc.src = cc.Macro.SRC_ALPHA;
+ blendFunc.dst = cc.Macro.ONE;
break;
case ccs.BLEND_TYPE_MULTIPLY:
- blendFunc.src = cc.DST_COLOR;
- blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA;
+ blendFunc.src = cc.Macro.DST_COLOR;
+ blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA;
break;
case ccs.BLEND_TYPE_SCREEN:
- blendFunc.src = cc.ONE;
- blendFunc.dst = cc.ONE_MINUS_DST_COLOR;
+ blendFunc.src = cc.Macro.ONE;
+ blendFunc.dst = cc.Macro.ONE_MINUS_DST_COLOR;
break;
default:
- frameData.blendFunc.src = cc.BLEND_SRC;
- frameData.blendFunc.dst = cc.BLEND_DST;
+ frameData.blendFunc.src = cc.Macro.BLEND_SRC;
+ frameData.blendFunc.dst = cc.Macro.BLEND_DST;
break;
}
}
@@ -937,8 +937,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{
frameData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.LINEAR;
frameData.displayIndex = json[ccs.CONST_A_DISPLAY_INDEX];
- var bd_src = json[ccs.CONST_A_BLEND_SRC] == null ? cc.BLEND_SRC : json[ccs.CONST_A_BLEND_SRC];
- var bd_dst = json[ccs.CONST_A_BLEND_DST] == null ? cc.BLEND_DST : json[ccs.CONST_A_BLEND_DST];
+ var bd_src = json[ccs.CONST_A_BLEND_SRC] == null ? cc.Macro.BLEND_SRC : json[ccs.CONST_A_BLEND_SRC];
+ var bd_dst = json[ccs.CONST_A_BLEND_DST] == null ? cc.Macro.BLEND_DST : json[ccs.CONST_A_BLEND_DST];
frameData.blendFunc.src = bd_src;
frameData.blendFunc.dst = bd_dst;
frameData.isTween = json[ccs.CONST_A_TWEEN_FRAME] == null ? true : json[ccs.CONST_A_TWEEN_FRAME];
diff --git a/extensions/gui/control-extension/CCControlStepper.js b/extensions/gui/control-extension/CCControlStepper.js
index c529b75ae0..fb0e8c97eb 100644
--- a/extensions/gui/control-extension/CCControlStepper.js
+++ b/extensions/gui/control-extension/CCControlStepper.js
@@ -221,7 +221,7 @@ cc.ControlStepper = cc.Control.extend(/** @lends cc.ControlStepper# */{
startAutorepeat:function () {
this._autorepeatCount = -1;
- this.schedule(this.update, cc.AUTOREPEAT_DELTATIME, cc.REPEAT_FOREVER, cc.AUTOREPEAT_DELTATIME * 3);
+ this.schedule(this.update, cc.AUTOREPEAT_DELTATIME, cc.Macro.REPEAT_FOREVER, cc.AUTOREPEAT_DELTATIME * 3);
},
/** Stop the autorepeat. */
diff --git a/extensions/gui/scrollview/CCSorting.js b/extensions/gui/scrollview/CCSorting.js
index 7902018171..d9e43b88c1 100644
--- a/extensions/gui/scrollview/CCSorting.js
+++ b/extensions/gui/scrollview/CCSorting.js
@@ -108,7 +108,7 @@ cc.ArrayForObjectSorting = cc._Class.extend(/** @lends cc.ArrayForObjectSorting#
}
var idx = this.indexOfSortedObject(delObject);
- if (idx < this.count() && idx !== cc.INVALID_INDEX) {
+ if (idx < this.count() && idx !== cc.Macro.INVALID_INDEX) {
var foundObj = this.objectAtIndex(idx);
if (foundObj.getObjectID() === delObject.getObjectID()) {
this.removeObjectAtIndex(idx);
@@ -129,7 +129,7 @@ cc.ArrayForObjectSorting = cc._Class.extend(/** @lends cc.ArrayForObjectSorting#
*/
setObjectID_ofSortedObject:function (tag, setObject) {
var idx = this.indexOfSortedObject(setObject);
- if (idx < this.count() && idx !== cc.INVALID_INDEX) {
+ if (idx < this.count() && idx !== cc.Macro.INVALID_INDEX) {
var foundObj = this.objectAtIndex(idx);
if (foundObj.getObjectID() === setObject.getObjectID()) {
this.removeObjectAtIndex(idx);
@@ -147,7 +147,7 @@ cc.ArrayForObjectSorting = cc._Class.extend(/** @lends cc.ArrayForObjectSorting#
foundObj.setObjectID(tag);
var idx = this.indexOfSortedObject(foundObj);
- if (idx < this.count() && idx !== cc.INVALID_INDEX) {
+ if (idx < this.count() && idx !== cc.Macro.INVALID_INDEX) {
foundObj = this.objectAtIndex(idx);
if (foundObj.getObjectID() !== tag)
foundObj = null;
@@ -201,7 +201,7 @@ cc.ArrayForObjectSorting = cc._Class.extend(/** @lends cc.ArrayForObjectSorting#
idx++;
}
} else {
- idx = cc.INVALID_INDEX;
+ idx = cc.Macro.INVALID_INDEX;
}
return idx;
},
diff --git a/extensions/gui/scrollview/CCTableView.js b/extensions/gui/scrollview/CCTableView.js
index ee312132ef..f3992593e5 100644
--- a/extensions/gui/scrollview/CCTableView.js
+++ b/extensions/gui/scrollview/CCTableView.js
@@ -65,7 +65,7 @@ cc.TableViewCell = _ccsg.Node.extend(/** @lends cc.TableViewCell# */{
* Cleans up any resources linked to this cell and resets idx property.
*/
reset:function () {
- this._idx = cc.INVALID_INDEX;
+ this._idx = cc.Macro.INVALID_INDEX;
},
setObjectID:function (idx) {
@@ -257,7 +257,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{
if (index !== -1) {
index = Math.max(0, index);
if (index > maxIdx)
- index = cc.INVALID_INDEX;
+ index = cc.Macro.INVALID_INDEX;
}
return index;
},
@@ -428,7 +428,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{
* @param idx index to find a cell
*/
updateCellAtIndex:function (idx) {
- if (idx === cc.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1)
+ if (idx === cc.Macro.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1)
return;
var cell = this.cellAtIndex(idx);
@@ -446,7 +446,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{
* @param idx location to insert
*/
insertCellAtIndex:function (idx) {
- if (idx === cc.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1)
+ if (idx === cc.Macro.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1)
return;
var newIdx, locCellsUsed = this._cellsUsed;
@@ -474,7 +474,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{
* @param idx index to find a cell
*/
removeCellAtIndex:function (idx) {
- if (idx === cc.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1)
+ if (idx === cc.Macro.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1)
return;
var cell = this.cellAtIndex(idx);
@@ -569,7 +569,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{
if (this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN)
offset.y = offset.y + locViewSize.height/locContainer.getScaleY();
var startIdx = this._indexFromOffset(offset);
- if (startIdx === cc.INVALID_INDEX)
+ if (startIdx === cc.Macro.INVALID_INDEX)
startIdx = countOfItems - 1;
if (this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN)
@@ -579,7 +579,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{
offset.x += locViewSize.width/locContainer.getScaleX();
var endIdx = this._indexFromOffset(offset);
- if (endIdx === cc.INVALID_INDEX)
+ if (endIdx === cc.Macro.INVALID_INDEX)
endIdx = countOfItems - 1;
var cell, locCellsUsed = this._cellsUsed;
@@ -656,7 +656,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{
point = this.getContainer().convertTouchToNodeSpace(touch);
index = this._indexFromOffset(point);
- if (index === cc.INVALID_INDEX)
+ if (index === cc.Macro.INVALID_INDEX)
this._touchedCell = null;
else
this._touchedCell = this.cellAtIndex(index);
diff --git a/extensions/spine/SGSkeleton.js b/extensions/spine/SGSkeleton.js
index 5d2ca1a7b0..d96a50c93a 100644
--- a/extensions/spine/SGSkeleton.js
+++ b/extensions/spine/SGSkeleton.js
@@ -40,7 +40,7 @@ sp._SGSkeleton = _ccsg.Node.extend({
ctor: function(skeletonDataFile, atlasFile, scale) {
_ccsg.Node.prototype.ctor.call(this);
- this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST};
+ this._blendFunc = {src: cc.Macro.BLEND_SRC, dst: cc.Macro.BLEND_DST};
if(arguments.length === 0)
this.init();
@@ -58,8 +58,8 @@ sp._SGSkeleton = _ccsg.Node.extend({
init: function () {
_ccsg.Node.prototype.init.call(this);
//this.setOpacityModifyRGB(true);
- this._blendFunc.src = cc.ONE;
- this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA;
+ this._blendFunc.src = cc.Macro.ONE;
+ this._blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA;
this.scheduleUpdate();
},
@@ -148,7 +148,7 @@ sp._SGSkeleton = _ccsg.Node.extend({
* @returns {cc.Rect}
*/
getBoundingBox: function () {
- var minX = cc.FLT_MAX, minY = cc.FLT_MAX, maxX = cc.FLT_MIN, maxY = cc.FLT_MIN;
+ var minX = cc.Macro.FLT_MAX, minY = cc.Macro.FLT_MAX, maxX = cc.Macro.FLT_MIN, maxY = cc.Macro.FLT_MIN;
var scaleX = this.getScaleX(), scaleY = this.getScaleY(), vertices = [],
slots = this._skeleton.slots, VERTEX = sp.VERTEX_INDEX;
diff --git a/extensions/spine/SGSkeletonWebGLRenderCmd.js b/extensions/spine/SGSkeletonWebGLRenderCmd.js
index 11355a9b92..524065302e 100644
--- a/extensions/spine/SGSkeletonWebGLRenderCmd.js
+++ b/extensions/spine/SGSkeletonWebGLRenderCmd.js
@@ -28,7 +28,7 @@ var spine = sp.spine;
sp._SGSkeleton.WebGLRenderCmd = function (renderableObject) {
_ccsg.Node.WebGLRenderCmd.call(this, renderableObject);
this._needDraw = true;
- this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR));
+ this.setShaderProgram(cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR));
this._tmpQuad = new cc.V3F_C4B_T2F_Quad();
};
@@ -86,13 +86,13 @@ proto.rendering = function (ctx) {
blendMode = slot.data.blendMode;
switch (blendMode) {
case spine.BlendMode.additive:
- cc.glBlendFunc(premultiAlpha ? cc.ONE : cc.SRC_ALPHA, cc.ONE);
+ cc.glBlendFunc(premultiAlpha ? cc.Macro.ONE : cc.Macro.SRC_ALPHA, cc.Macro.ONE);
break;
case spine.BlendMode.multiply:
- cc.glBlendFunc(cc.DST_COLOR, cc.ONE_MINUS_SRC_ALPHA);
+ cc.glBlendFunc(cc.Macro.DST_COLOR, cc.Macro.ONE_MINUS_SRC_ALPHA);
break;
case spine.BlendMode.screen:
- cc.glBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_COLOR);
+ cc.glBlendFunc(cc.Macro.ONE, cc.Macro.ONE_MINUS_SRC_COLOR);
break;
default:
cc.glBlendFunc(locBlendFunc.src, locBlendFunc.dst);
diff --git a/external/gaf/Library/GAFShaderManager.js b/external/gaf/Library/GAFShaderManager.js
index 49b7ffba0f..4bb314ce0a 100644
--- a/external/gaf/Library/GAFShaderManager.js
+++ b/external/gaf/Library/GAFShaderManager.js
@@ -14,9 +14,9 @@ gaf._glShaderInit = function() {
var program = new cc.GLProgram();
var result = program.initWithVertexShaderByteArray(vs, fs);
cc.assert(result, "Shader init error");
- program.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- program.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
- program.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
+ program.addAttribute(cc.Macro.ATTRIBUTE_NAME_POSITION, cc.Macro.VERTEX_ATTRIB_POSITION);
+ program.addAttribute(cc.Macro.ATTRIBUTE_NAME_COLOR, cc.Macro.VERTEX_ATTRIB_COLOR);
+ program.addAttribute(cc.Macro.ATTRIBUTE_NAME_TEX_COORD, cc.Macro.VERTEX_ATTRIB_TEX_COORDS);
result = program.link();
cc.assert(result, "Shader linking error");
program.updateUniforms();
@@ -24,7 +24,7 @@ gaf._glShaderInit = function() {
};
gaf._shaderCreateAlpha = function () {
- var program = gaf._shaderCreate(gaf.SHADER_COLOR_MATRIX_FRAG, cc.SHADER_POSITION_TEXTURE_COLOR_VERT);
+ var program = gaf._shaderCreate(gaf.SHADER_COLOR_MATRIX_FRAG, cc.Shaders.POSITION_TEXTURE_COLOR_VERT);
gaf._Uniforms.ColorTransformMult = program.getUniformLocationForName(gaf.UNIFORM_ALPHA_TINT_MULT);
gaf._Uniforms.ColorTransformOffset = program.getUniformLocationForName(gaf.UNIFORM_ALPHA_TINT_OFFSET);
gaf._Uniforms.ColorMatrixBody = program.getUniformLocationForName(gaf.UNIFORM_ALPHA_COLOR_MATRIX_BODY);
@@ -33,14 +33,14 @@ gaf._glShaderInit = function() {
};
gaf._shaderCreateBlur = function () {
- var program = gaf._shaderCreate(gaf.SHADER_GAUSSIAN_BLUR_FRAG, cc.SHADER_POSITION_TEXTURE_COLOR_VERT);
+ var program = gaf._shaderCreate(gaf.SHADER_GAUSSIAN_BLUR_FRAG, cc.Shaders.POSITION_TEXTURE_COLOR_VERT);
gaf._Uniforms.BlurTexelOffset = program._glContext.getUniformLocation(program._programObj, gaf.UNIFORM_BLUR_TEXEL_OFFSET);
return program;
};
gaf._shaderCreateGlow = function () {
- var program = gaf._shaderCreate(gaf.SHADER_GLOW_FRAG, cc.SHADER_POSITION_TEXTURE_COLOR_VERT);
+ var program = gaf._shaderCreate(gaf.SHADER_GLOW_FRAG, cc.Shaders.POSITION_TEXTURE_COLOR_VERT);
gaf._Uniforms.GlowTexelOffset = program._glContext.getUniformLocation(program._programObj, gaf.UNIFORM_GLOW_TEXEL_OFFSET);
gaf._Uniforms.GlowColor = program._glContext.getUniformLocation(program._programObj, gaf.UNIFORM_GLOW_COLOR);
return program;
diff --git a/external/gaf/Library/GAFSpriteWebGLRenderCmd.js b/external/gaf/Library/GAFSpriteWebGLRenderCmd.js
index 58a48b8c02..127d2a7f6a 100644
--- a/external/gaf/Library/GAFSpriteWebGLRenderCmd.js
+++ b/external/gaf/Library/GAFSpriteWebGLRenderCmd.js
@@ -2,7 +2,7 @@
(function(){
gaf.Sprite.WebGLRenderCmd = function (renderable) {
_ccsg.Sprite.WebGLRenderCmd.call(this, renderable);
- this._defualtShader = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
+ this._defualtShader = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR);
this._customShader = gaf._Shaders.Alpha;
//this._shaderProgram = this._defualtShader;
diff --git a/gulp/tasks/build-cocos2d.js b/gulp/tasks/build-cocos2d.js
index eb14e7b6e1..b2b9ff65bd 100644
--- a/gulp/tasks/build-cocos2d.js
+++ b/gulp/tasks/build-cocos2d.js
@@ -35,9 +35,7 @@ var srcs = [
'./Base64Images.js',
'./CCBoot.js',
- './cocos2d/core/platform/CCCommon.js',
'./cocos2d/core/platform/CCSAXParser.js',
- './cocos2d/core/platform/CCConfig.js',
'./cocos2d/core/platform/miniFramework.js',
'./cocos2d/core/platform/CCEGLView.js',
'./cocos2d/core/platform/CCScreen.js',
diff --git a/jsb/index.js b/jsb/index.js
index c514fe4d40..2168ae876b 100644
--- a/jsb/index.js
+++ b/jsb/index.js
@@ -39,7 +39,7 @@ cc.initEngine = function (config, cb) {
try {
var originLog = console.log;
console.log = function () {
- originLog.call(console, cc.formatStr.apply(null, arguments));
+ originLog.call(console, cc.js.formatStr.apply(null, arguments));
};
}
catch (e) {
diff --git a/predefine.js b/predefine.js
index 56ba694d85..da92d6de01 100644
--- a/predefine.js
+++ b/predefine.js
@@ -57,6 +57,7 @@ require('./cocos2d/core/platform/CCInputManager');
require('./cocos2d/core/platform/CCInputExtension');
require('./cocos2d/core/event');
require('./cocos2d/core/platform/CCSys');
+require('./cocos2d/core/platform/CCMacro');
require('./cocos2d/core/load-pipeline');
require('./cocos2d/core/CCDirector');
require('./cocos2d/core/CCDirectorWebGL');
diff --git a/test/visual-tests/main.js b/test/visual-tests/main.js
index ffb7e4f6ff..3bd1dbc8e9 100644
--- a/test/visual-tests/main.js
+++ b/test/visual-tests/main.js
@@ -110,6 +110,8 @@ cc.game.run({
"../../cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js",
"../../cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js",
+ "../../cocos2d/actions/CCActionCatmullRom.js",
+
"src/BaseTestLayer/BaseTestLayer.js",
"src/tests_resources.js",
diff --git a/test/visual-tests/src/ClippingNodeTest/ClippingNodeTest.js b/test/visual-tests/src/ClippingNodeTest/ClippingNodeTest.js
index 3aefcee7a8..e6b4d72a31 100644
--- a/test/visual-tests/src/ClippingNodeTest/ClippingNodeTest.js
+++ b/test/visual-tests/src/ClippingNodeTest/ClippingNodeTest.js
@@ -620,8 +620,8 @@ var RawStencilBufferTest4 = RawStencilBufferTest.extend({
this._super(plane);
gl.depthMask(false);
- var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
- var alphaValueLocation = gl.getUniformLocation(program.getProgram(),cc.UNIFORM_ALPHA_TEST_VALUE_S);
+ var program = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLORALPHATEST);
+ var alphaValueLocation = gl.getUniformLocation(program.getProgram(),cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S);
cc.glUseProgram(program.getProgram());
program.setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
this._sprite.shaderProgram = program;
@@ -644,8 +644,8 @@ var RawStencilBufferTest5 = RawStencilBufferTest.extend({
gl.disable(gl.DEPTH_TEST);
gl.depthMask(false);
- var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
- var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S);
+ var program = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLORALPHATEST);
+ var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S);
cc.glUseProgram(program.getProgram());
program.setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
this._sprite.shaderProgram = program;
@@ -680,8 +680,8 @@ var RawStencilBufferTest6 = RawStencilBufferTest.extend({
gl.disable(gl.DEPTH_TEST);
gl.depthMask(false);
- var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
- var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S);
+ var program = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLORALPHATEST);
+ var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S);
cc.glUseProgram(program.getProgram());
program.setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
this._sprite.shaderProgram = program;
diff --git a/test/visual-tests/src/CocosNodeTest/CocosNodeTest.js b/test/visual-tests/src/CocosNodeTest/CocosNodeTest.js
index eb636e5a76..f11089f687 100644
--- a/test/visual-tests/src/CocosNodeTest/CocosNodeTest.js
+++ b/test/visual-tests/src/CocosNodeTest/CocosNodeTest.js
@@ -740,7 +740,7 @@ var NodeOpaqueTest = TestNodeDemo.extend({
var background;
for (var i = 0; i < 50; i++) {
background = new _ccsg.Sprite(s_back1);
- background.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA);
+ background.setBlendFunc(cc.Macro.ONE, cc.Macro.ONE_MINUS_SRC_ALPHA);
background.x = winSize.width / 2;
background.y = winSize.height / 2;
this.addChild(background);
@@ -765,7 +765,7 @@ var NodeNonOpaqueTest = TestNodeDemo.extend({
var background;
for (var i = 0; i < 50; i++) {
background = new _ccsg.Sprite(s_back1);
- background.setBlendFunc(cc.ONE, cc.ZERO);
+ background.setBlendFunc(cc.Macro.ONE, cc.Macro.ZERO);
background.x = winSize.width / 2;
background.y = winSize.height / 2;
this.addChild(background);
diff --git a/test/visual-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js b/test/visual-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js
index 29b589c714..c52b6ef46b 100644
--- a/test/visual-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js
+++ b/test/visual-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js
@@ -219,11 +219,11 @@ var S9Actiontest = S9SpriteTestDemo.extend({
this.addChild(s9sprite1);
var actionArray = [];
- actionArray.push(cc.DelayTime.create(1));
- actionArray.push(cc.MoveBy.create(1,x/2, 0));
- actionArray.push(cc.RotateBy.create(2,360));
- actionArray.push(cc.ScaleBy.create(1,2));
- s9sprite1.runAction(cc.Sequence.create(actionArray));
+ actionArray.push(cc.delayTime(1));
+ actionArray.push(cc.moveBy(1,x/2, 0));
+ actionArray.push(cc.rotateBy(2,360));
+ actionArray.push(cc.scaleBy(1,2));
+ s9sprite1.runAction(cc.sequence(actionArray));
}
});
@@ -245,11 +245,11 @@ var S9ChangeFiletest = S9SpriteTestDemo.extend({
this.addChild(_s9sprite1);
var actionArray = [];
- actionArray.push(cc.DelayTime.create(1));
- actionArray.push(cc.CallFunc.create(this.changeFile1,this));
- actionArray.push(cc.DelayTime.create(2));
- actionArray.push(cc.CallFunc.create(this.changeFile2,this));
- _s9sprite1.runAction(cc.Sequence.create(actionArray));
+ actionArray.push(cc.delayTime(1));
+ actionArray.push(cc.callFunc(this.changeFile1,this));
+ actionArray.push(cc.delayTime(2));
+ actionArray.push(cc.callFunc(this.changeFile2,this));
+ _s9sprite1.runAction(cc.sequence(actionArray));
},
changeFile1: function() {
this.changeFile("res/Images/btn-highscores-normal.png");
diff --git a/test/visual-tests/src/LabelTest/LabelTest.js b/test/visual-tests/src/LabelTest/LabelTest.js
index 02fb0fe84f..883fa2fe37 100644
--- a/test/visual-tests/src/LabelTest/LabelTest.js
+++ b/test/visual-tests/src/LabelTest/LabelTest.js
@@ -2006,11 +2006,11 @@ var WrapAlgorithmTest = AtlasDemo.extend({
},
onEnter: function(){
this._super();
- cc.SPRITE_DEBUG_DRAW = 1;
+ cc.Macro.SPRITE_DEBUG_DRAW = 1;
},
onExit: function(){
this._super();
- cc.SPRITE_DEBUG_DRAW = 0;
+ cc.Macro.SPRITE_DEBUG_DRAW = 0;
}
});
diff --git a/test/visual-tests/src/LayerTest/LayerTest.js b/test/visual-tests/src/LayerTest/LayerTest.js
index 3213630316..e73f979a73 100644
--- a/test/visual-tests/src/LayerTest/LayerTest.js
+++ b/test/visual-tests/src/LayerTest/LayerTest.js
@@ -428,11 +428,11 @@ var LayerTestBlend = LayerTest.extend({
var dst;
if (this._blend) {
- src = cc.SRC_ALPHA;
- dst = cc.ONE_MINUS_SRC_ALPHA;
+ src = cc.Macro.SRC_ALPHA;
+ dst = cc.Macro.ONE_MINUS_SRC_ALPHA;
} else {
- src = cc.ONE_MINUS_DST_COLOR;
- dst = cc.ZERO;
+ src = cc.Macro.ONE_MINUS_DST_COLOR;
+ dst = cc.Macro.ZERO;
}
layer.setBlendFunc( src, dst );
this._blend = ! this._blend;
diff --git a/test/visual-tests/src/OpenGLTest/OpenGLTest.js b/test/visual-tests/src/OpenGLTest/OpenGLTest.js
index a942e8813a..ba5eba2b31 100644
--- a/test/visual-tests/src/OpenGLTest/OpenGLTest.js
+++ b/test/visual-tests/src/OpenGLTest/OpenGLTest.js
@@ -458,23 +458,23 @@ var GLNodeCCAPITest = OpenGLTestLayer.extend({
this.shader.use();
this.shader.setUniformsForBuiltins();
- cc.glEnableVertexAttribs( cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs( cc.Macro.VERTEX_ATTRIB_FLAG_COLOR | cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
// Draw fullscreen Square
gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexColorBuffer);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
// Draw fullscreen Triangle
gl.bindBuffer(gl.ARRAY_BUFFER, this.triangleVertexPositionBuffer);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, this.triangleVertexColorBuffer);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3);
@@ -574,7 +574,7 @@ var ShaderNode = cc.GLNode.extend({
this.shader = cc.GLProgram.create(vertexShader, framentShader);
this.shader.retain();
- this.shader.addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION);
+ this.shader.addAttribute("aVertex", cc.Macro.VERTEX_ATTRIB_POSITION);
this.shader.link();
this.shader.updateUniforms();
@@ -604,11 +604,11 @@ var ShaderNode = cc.GLNode.extend({
this.shader.setUniformLocationF32( this.uniformCenter, centerx, centery);
this.shader.setUniformLocationF32( this.uniformResolution, 256, 256);
- cc.glEnableVertexAttribs( cc.VERTEX_ATTRIB_FLAG_POSITION );
+ cc.glEnableVertexAttribs( cc.Macro.VERTEX_ATTRIB_FLAG_POSITION );
// Draw fullscreen Square
gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
@@ -879,9 +879,9 @@ var ShaderOutlineEffect = OpenGLTestLayer.extend({
}
else{
this.shader = new cc.GLProgram("res/Shaders/example_Outline.vsh", "res/Shaders/example_Outline.fsh");
- this.shader.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- this.shader.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
- this.shader.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
+ this.shader.addAttribute(cc.Macro.ATTRIBUTE_NAME_POSITION, cc.Macro.VERTEX_ATTRIB_POSITION);
+ this.shader.addAttribute(cc.Macro.ATTRIBUTE_NAME_TEX_COORD, cc.Macro.VERTEX_ATTRIB_TEX_COORDS);
+ this.shader.addAttribute(cc.Macro.ATTRIBUTE_NAME_COLOR, cc.Macro.VERTEX_ATTRIB_COLOR);
this.shader.link();
this.shader.updateUniforms();
@@ -950,8 +950,8 @@ var ShaderRetroEffect = OpenGLTestLayer.extend({
if( 'opengl' in cc.sys.capabilities ) {
var program = new cc.GLProgram("res/Shaders/example_ColorBars.vsh", "res/Shaders/example_ColorBars.fsh");
- program.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- program.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
+ program.addAttribute(cc.Macro.ATTRIBUTE_NAME_POSITION, cc.Macro.VERTEX_ATTRIB_POSITION);
+ program.addAttribute(cc.Macro.ATTRIBUTE_NAME_TEX_COORD, cc.Macro.VERTEX_ATTRIB_TEX_COORDS);
program.link();
program.updateUniforms();
@@ -1088,14 +1088,14 @@ var TexImage2DTest = OpenGLTestLayer.extend({
this.shader.setUniformsForBuiltins();
gl.bindTexture(gl.TEXTURE_2D, this.my_texture);
- cc.glEnableVertexAttribs( cc.VERTEX_ATTRIB_FLAG_TEX_COORDS | cc.VERTEX_ATTRIB_FLAG_POSITION);
+ cc.glEnableVertexAttribs( cc.Macro.VERTEX_ATTRIB_FLAG_TEX_COORDS | cc.Macro.VERTEX_ATTRIB_FLAG_POSITION);
// Draw fullscreen Square
gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexTextureBuffer);
- gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, 0);
+ gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
diff --git a/test/visual-tests/src/ParallaxTest/ParallaxTest.js b/test/visual-tests/src/ParallaxTest/ParallaxTest.js
index c9ac3661f5..f74d4429e8 100644
--- a/test/visual-tests/src/ParallaxTest/ParallaxTest.js
+++ b/test/visual-tests/src/ParallaxTest/ParallaxTest.js
@@ -84,7 +84,7 @@ var Parallax1 = ParallaxDemo.extend({
// Middle layer: a Tile map atlas
//var tilemap = cc.TileMapAtlas.create(s_tilesPng, s_levelMapTga, 16, 16);
- this._tilemap = new cc.TMXTiledMap("res/TileMaps/orthogonal-test2.tmx");
+ this._tilemap = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test2.tmx");
// change the transform anchor to 0,0 (optional)
this._tilemap.anchorX = 0;
@@ -197,7 +197,7 @@ var Parallax2 = ParallaxDemo.extend({
// Middle layer: a Tile map atlas
//var tilemap = cc.TileMapAtlas.create(s_tilesPng, s_levelMapTga, 16, 16);
- var tilemap = new cc.TMXTiledMap("res/TileMaps/orthogonal-test2.tmx");
+ var tilemap = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test2.tmx");
// change the transform anchor to 0,0 (optional)
tilemap.anchorX = 0;
diff --git a/test/visual-tests/src/SchedulerTest/SchedulerTest.js b/test/visual-tests/src/SchedulerTest/SchedulerTest.js
index 69104d3fab..050f7be692 100644
--- a/test/visual-tests/src/SchedulerTest/SchedulerTest.js
+++ b/test/visual-tests/src/SchedulerTest/SchedulerTest.js
@@ -496,7 +496,7 @@ var ScheduleUsingSchedulerTest = SchedulerTestLayer.extend({
scheduler.scheduleUpdateForTarget(this, priority, paused);
var interval = 0.25; // every 1/4 of second
- var repeat = cc.REPEAT_FOREVER; // how many repeats. cc.REPEAT_FOREVER means forever
+ var repeat = cc.Macro.REPEAT_FOREVER; // how many repeats. cc.Macro.REPEAT_FOREVER means forever
var delay = 2; // start after 2 seconds;
paused = false; // not paused. queue it now.
scheduler.scheduleCallbackForTarget(this, this.onSchedUpdate, interval, repeat, delay, paused);
diff --git a/test/visual-tests/src/SpriteTest/SpriteTest.js b/test/visual-tests/src/SpriteTest/SpriteTest.js
index d5d765b266..ef6e0606bf 100644
--- a/test/visual-tests/src/SpriteTest/SpriteTest.js
+++ b/test/visual-tests/src/SpriteTest/SpriteTest.js
@@ -994,7 +994,7 @@ var SpriteZVertex = SpriteTestDemo.extend({
//
var alphaTestShader = cc.shaderCache.getProgram("ShaderPositionTextureColorAlphaTest");
var glprogram = alphaTestShader.getProgram();
- var alphaValueLocation = gl.getUniformLocation(glprogram, cc.UNIFORM_ALPHA_TEST_VALUE_S);
+ var alphaValueLocation = gl.getUniformLocation(glprogram, cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S);
// set alpha test value
// NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison
@@ -1118,7 +1118,7 @@ var SpriteBatchNodeZVertex = SpriteTestDemo.extend({
//
var alphaTestShader = cc.shaderCache.getProgram("ShaderPositionTextureColorAlphaTest");
var glprogram = alphaTestShader.getProgram();
- var alphaValueLocation = gl.getUniformLocation(glprogram, cc.UNIFORM_ALPHA_TEST_VALUE_S);
+ var alphaValueLocation = gl.getUniformLocation(glprogram, cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S);
// set alpha test value
// NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison
@@ -5200,7 +5200,7 @@ var TextureRotatedSpriteFrame = SpriteTestDemo.extend({
var SpriteWithRepeatingTexture = SpriteTestDemo.extend({
_title:"Sprite with Repeating texture",
- _subtitle:"aTexture.setTexParameters(cc.LINEAR, cc.LINEAR, cc.Texture2D.WrapMode.REPEAT, cc.Texture2D.WrapMode.REPEAT);",
+ _subtitle:"aTexture.setTexParameters(cc.Macro.LINEAR, cc.Macro.LINEAR, cc.Texture2D.WrapMode.REPEAT, cc.Texture2D.WrapMode.REPEAT);",
ctor:function () {
//----start58----ctor
@@ -5212,7 +5212,7 @@ var SpriteWithRepeatingTexture = SpriteTestDemo.extend({
block.setTextureRect(cc.rect(0,0, 320,240));
block.setPosition(x, y);
- block.getTexture().setTexParameters(cc.LINEAR, cc.LINEAR, cc.Texture2D.WrapMode.REPEAT, cc.Texture2D.WrapMode.REPEAT);
+ block.getTexture().setTexParameters(cc.Macro.LINEAR, cc.Macro.LINEAR, cc.Texture2D.WrapMode.REPEAT, cc.Texture2D.WrapMode.REPEAT);
this.addChild(block);
//----end58----
}
@@ -5227,8 +5227,8 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({
//----start59----ctor
this._super();
- var destFactors = [cc.ZERO, cc.ONE, cc.DST_COLOR, cc.ONE_MINUS_DST_COLOR, cc.DST_ALPHA, cc.ONE_MINUS_DST_ALPHA],
- srcFactors = [cc.ZERO, cc.ONE, cc.SRC_COLOR, cc.ONE_MINUS_SRC_COLOR, cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA];
+ var destFactors = [cc.Macro.ZERO, cc.Macro.ONE, cc.Macro.DST_COLOR, cc.Macro.ONE_MINUS_DST_COLOR, cc.Macro.DST_ALPHA, cc.Macro.ONE_MINUS_DST_ALPHA],
+ srcFactors = [cc.Macro.ZERO, cc.Macro.ONE, cc.Macro.SRC_COLOR, cc.Macro.ONE_MINUS_SRC_COLOR, cc.Macro.SRC_ALPHA, cc.Macro.ONE_MINUS_SRC_ALPHA];
var destTitles = ["ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "DST_ALPHA", "ONE_MINUS_DST_ALPHA"],
srcTitles = ["ZERO", "ONE", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"];
@@ -5359,7 +5359,7 @@ var arrayOfSpriteTest = [
NodeSort,
SpriteSkewNegativeScaleChildren,
SpriteBatchNodeSkewNegativeScaleChildren,
- SpriteDoubleResolution,
+ // SpriteDoubleResolution,
SpriteBatchBug1217,
SpriteFrameAnimationCacheFile,
TextureColorCacheIssue,
diff --git a/test/visual-tests/src/TileMapTest/TileMapTest.js b/test/visual-tests/src/TileMapTest/TileMapTest.js
index 11e4e48b71..e83833d7bf 100644
--- a/test/visual-tests/src/TileMapTest/TileMapTest.js
+++ b/test/visual-tests/src/TileMapTest/TileMapTest.js
@@ -175,7 +175,7 @@ var TileMapEditTest = TileDemo.extend({
var TMXOrthoTest = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test1.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test1.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
map.runAction(new cc.ScaleBy(2, 0.5));
@@ -217,7 +217,7 @@ var TMXOrthoTest2 = TileDemo.extend({
//
// it should not flicker. No artifacts should appear
//
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test2.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test2.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
},
title:function () {
@@ -260,7 +260,7 @@ var TMXOrthoTest2 = TileDemo.extend({
var TMXOrthoTest3 = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test3.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test3.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
map.scale = 0.2;
@@ -298,7 +298,7 @@ var TMXOrthoTest3 = TileDemo.extend({
var TMXOrthoTest4 = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test4.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test4.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
map.anchorX = 0;
@@ -368,7 +368,7 @@ var TMXReadWriteTest = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test2.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test2.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
var layer = map.getLayer("Layer 0");
@@ -490,7 +490,7 @@ var TMXHexTest = TileDemo.extend({
var color = new cc.LayerColor(cc.color(64, 64, 64, 255));
this.addChild(color, -1);
- var map = new cc.TMXTiledMap("res/TileMaps/hexa-test.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/hexa-test.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
},
title:function () {
@@ -526,7 +526,7 @@ var TMXIsoTest = TileDemo.extend({
var color = new cc.LayerColor(cc.color(64, 64, 64, 255));
this.addChild(color, -1);
- var map = new cc.TMXTiledMap("res/TileMaps/iso-test.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/iso-test.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
// move map to the center of the screen
@@ -570,7 +570,7 @@ var TMXIsoTest1 = TileDemo.extend({
var color = new cc.LayerColor(cc.color(64, 64, 64, 255));
this.addChild(color, -1);
- var map = new cc.TMXTiledMap("res/TileMaps/iso-test1.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/iso-test1.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
map.anchorX = 0.5;
@@ -612,7 +612,7 @@ var TMXIsoTest2 = TileDemo.extend({
var color = new cc.LayerColor(cc.color(64, 64, 64, 255));
this.addChild(color, -1);
- var map = new cc.TMXTiledMap("res/TileMaps/iso-test2.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/iso-test2.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
// move map to the center of the screen
@@ -657,7 +657,7 @@ var TMXUncompressedTest = TileDemo.extend({
var color = new cc.LayerColor(cc.color(64, 64, 64, 255));
this.addChild(color, -1);
- var map = new cc.TMXTiledMap("res/TileMaps/iso-test2-uncompressed.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/iso-test2-uncompressed.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
// move map to the center of the screen
@@ -710,7 +710,7 @@ var TMXUncompressedTest = TileDemo.extend({
var TMXTilesetTest = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test5.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test5.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
if ("opengl" in cc.sys.capabilities) {
@@ -760,7 +760,7 @@ var TMXOrthoObjectsTest = TileDemo.extend({
drawNode.setLineWidth(3);
drawNode.setDrawColor(cc.color(255,255,255,255));
- var map = new cc.TMXTiledMap("res/TileMaps/ortho-objects.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/ortho-objects.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
var group = map.getObjectGroup("Object Group 1");
@@ -835,7 +835,7 @@ var TMXIsoObjectsTest = TileDemo.extend({
drawNode.setDrawColor(cc.color(255,255,255,255));
this.addChild(drawNode);
- var map = new cc.TMXTiledMap("res/TileMaps/iso-test-objectgroup.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/iso-test-objectgroup.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
var group = map.getObjectGroup("Object Group 1");
@@ -906,7 +906,7 @@ var TMXIsoObjectsTest = TileDemo.extend({
var TMXResizeTest = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test5.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test5.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
var layer;
@@ -950,7 +950,7 @@ var TMXIsoZorder = TileDemo.extend({
tamara:null,
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/iso-test-zorder.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/iso-test-zorder.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
map.x = -map.width / 2;
@@ -1019,7 +1019,7 @@ var TMXOrthoZorder = TileDemo.extend({
tamara:null,
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test-zorder.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test-zorder.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
this.tamara = new _ccsg.Sprite(s_pathSister1);
@@ -1082,7 +1082,7 @@ var TMXIsoVertexZ = TMXFixBugLayer.extend({
tamara:null,
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/iso-test-vertexz.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/iso-test-vertexz.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
map.x = -map.width / 2;
@@ -1157,7 +1157,7 @@ var TMXOrthoVertexZ = TMXFixBugLayer.extend({
tamara:null,
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test-vertexz.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test-vertexz.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
// because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
@@ -1231,7 +1231,7 @@ var TMXOrthoVertexZ = TMXFixBugLayer.extend({
var TMXIsoMoveLayer = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/iso-test-movelayer.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/iso-test-movelayer.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
map.x = -700;
map.y = -50;
@@ -1252,7 +1252,7 @@ var TMXIsoMoveLayer = TileDemo.extend({
var TMXOrthoMoveLayer = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test-movelayer.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test-movelayer.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
},
title:function () {
@@ -1271,7 +1271,7 @@ var TMXOrthoMoveLayer = TileDemo.extend({
var TMXTilePropertyTest = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/ortho-tile-property.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/ortho-tile-property.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
for (var i = 1; i <= 6; i++) {
@@ -1314,7 +1314,7 @@ var TMXTilePropertyTest = TileDemo.extend({
var TMXOrthoFlipTest = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/ortho-rotation-test.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/ortho-rotation-test.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
this.log("ContentSize:" + map.width + "," + map.height);
@@ -1350,7 +1350,7 @@ var TMXOrthoFlipTest = TileDemo.extend({
var TMXOrthoFlipRunTimeTest = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/ortho-rotation-test.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/ortho-rotation-test.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
this.log("ContentSize:" + map.width + "," + map.height);
@@ -1438,7 +1438,7 @@ var TMXOrthoFromXMLTest = TileDemo.extend({
var resources = "res/TileMaps";
var filePath = "res/TileMaps/orthogonal-test1.tmx";
var xmlStr = cc.loader.getRes(filePath);
- var map = new cc.TMXTiledMap(xmlStr, resources);
+ var map = new _ccsg.TMXTiledMap(xmlStr, resources);
this.addChild(map, 0, TAG_TILE_MAP);
cc.log("ContentSize: " + map.width + ", " + map.height);
@@ -1485,7 +1485,7 @@ var TMXOrthoFromXMLTest = TileDemo.extend({
var TMXBug987 = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/orthogonal-test6.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/orthogonal-test6.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
this.log("ContentSize:" + map.width + "," + map.height);
@@ -1540,7 +1540,7 @@ var TMXBug987 = TileDemo.extend({
var TMXBug787 = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/iso-test-bug787.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/iso-test-bug787.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
map.scale = 0.25;
@@ -1576,7 +1576,7 @@ var TMXGIDObjectsTest = TileDemo.extend({
drawNode.setDrawColor(cc.color(255,255,255,255));
this.addChild(drawNode);
- var map = new cc.TMXTiledMap("res/TileMaps/test-object-layer.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/test-object-layer.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
this.log("ContentSize:" + map.width + "," + map.height);
@@ -1639,7 +1639,7 @@ var TMXGIDObjectsTest = TileDemo.extend({
var TMXIsoOffsetTest = TileDemo.extend({
ctor:function () {
this._super();
- var map = new cc.TMXTiledMap("res/TileMaps/tile_iso_offset.tmx");
+ var map = new _ccsg.TMXTiledMap("res/TileMaps/tile_iso_offset.tmx");
this.addChild(map, 0, TAG_TILE_MAP);
},