Skip to content

Commit 2829558

Browse files
committed
Issue cocos2d#2698: refactor cc.pointApplyAffineTransform
1 parent 771fbdd commit 2829558

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

cocos2d/core/CCScheduler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ cc.TimerTargetCallback = cc.Timer.extend({
285285
*
286286
* @example
287287
* //register a schedule to scheduler
288-
* cc.director.getScheduler().scheduleSelector(callback, this, interval, !this._isRunning);
288+
* cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
289289
*/
290290
cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{
291291
_timeScale:1.0,

cocos2d/core/cocoa/CCAffineTransform.js

+24-15
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,26 @@ cc.affineTransformMake = function (a, b, c, d, tx, ty) {
6666
* Apply the affine transformation on a point.
6767
* @function
6868
*
69-
* @param {cc.Point} point
70-
* @param {cc.AffineTransform} t
69+
* @param {cc.Point|Number} point or x
70+
* @param {cc.AffineTransform|Number} transOrY transform matrix or y
71+
* @param {cc.AffineTransform} t transform matrix or y
7172
* @return {cc.Point}
7273
*/
73-
cc.pointApplyAffineTransform = function (point, t) {
74-
return {x: t.a * point.x + t.c * point.y + t.tx, y: t.b * point.x + t.d * point.y + t.ty};
74+
cc.pointApplyAffineTransform = function (point, transOrY, t) {
75+
var x, y;
76+
if (t === undefined) {
77+
t = transOrY;
78+
x = point.x;
79+
y = point.y;
80+
} else {
81+
x = point;
82+
y = transOrY;
83+
}
84+
return {x: t.a * x + t.c * y + t.tx, y: t.b * x + t.d * y + t.ty};
7585
};
7686

77-
cc._pointApplyAffineTransform = function (x, y, t) {
78-
return {x: t.a * x + t.c * y + t.tx,
79-
y: t.b * x + t.d * y + t.ty};
87+
cc._pointApplyAffineTransform = function (x, y, t) { //it will remove.
88+
return cc.pointApplyAffineTransform(x, y, t);
8089
};
8190

8291
/**
@@ -131,10 +140,10 @@ cc.rectApplyAffineTransform = function (rect, anAffineTransform) {
131140
var right = cc.rectGetMaxX(rect);
132141
var bottom = cc.rectGetMaxY(rect);
133142

134-
var topLeft = cc._pointApplyAffineTransform(left, top, anAffineTransform);
135-
var topRight = cc._pointApplyAffineTransform(right, top, anAffineTransform);
136-
var bottomLeft = cc._pointApplyAffineTransform(left, bottom, anAffineTransform);
137-
var bottomRight = cc._pointApplyAffineTransform(right, bottom, anAffineTransform);
143+
var topLeft = cc.pointApplyAffineTransform(left, top, anAffineTransform);
144+
var topRight = cc.pointApplyAffineTransform(right, top, anAffineTransform);
145+
var bottomLeft = cc.pointApplyAffineTransform(left, bottom, anAffineTransform);
146+
var bottomRight = cc.pointApplyAffineTransform(right, bottom, anAffineTransform);
138147

139148
var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
140149
var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
@@ -150,10 +159,10 @@ cc._rectApplyAffineTransformIn = function(rect, anAffineTransform){
150159
var right = cc.rectGetMaxX(rect);
151160
var bottom = cc.rectGetMaxY(rect);
152161

153-
var topLeft = cc._pointApplyAffineTransform(left, top, anAffineTransform);
154-
var topRight = cc._pointApplyAffineTransform(right, top, anAffineTransform);
155-
var bottomLeft = cc._pointApplyAffineTransform(left, bottom, anAffineTransform);
156-
var bottomRight = cc._pointApplyAffineTransform(right, bottom, anAffineTransform);
162+
var topLeft = cc.pointApplyAffineTransform(left, top, anAffineTransform);
163+
var topRight = cc.pointApplyAffineTransform(right, top, anAffineTransform);
164+
var bottomLeft = cc.pointApplyAffineTransform(left, bottom, anAffineTransform);
165+
var bottomRight = cc.pointApplyAffineTransform(right, bottom, anAffineTransform);
157166

158167
var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
159168
var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);

cocos2d/core/layers/CCLayer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ cc.LayerColor.create = function (color, width, height) {
313313
* @property {Number} startOpacity - Start opacity of the color gradient
314314
* @property {Number} endOpacity - End opacity of the color gradient
315315
* @property {Number} vector - Direction vector of the color gradient
316-
* @property {Number} compresseInterpolation - Indicate whether or not the interpolation will be compressed
316+
* @property {Number} compressedInterpolation - Indicate whether or not the interpolation will be compressed
317317
*/
318318
cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{
319319
_endColor: null,

cocos2d/core/layers/CCLayerWebGLRenderCmd.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@
247247
transMat = cc.affineTransformScale(transMat, tx, ty);
248248
for (i = 0; i < stopsLen; i++) {
249249
var stop = stops[i], y = stop.p * contentSize.height ;
250-
var p0 = cc._pointApplyAffineTransform(- locAnchor.x , y - locAnchor.y, transMat);
250+
var p0 = cc.pointApplyAffineTransform(- locAnchor.x , y - locAnchor.y, transMat);
251251
locVertices[i * 2].x = p0.x;
252252
locVertices[i * 2].y = p0.y;
253-
var p1 = cc._pointApplyAffineTransform(contentSize.width - locAnchor.x, y - locAnchor.y, transMat);
253+
var p1 = cc.pointApplyAffineTransform(contentSize.width - locAnchor.x, y - locAnchor.y, transMat);
254254
locVertices[i * 2 + 1].x = p1.x;
255255
locVertices[i * 2 + 1].y = p1.y;
256256
}

0 commit comments

Comments
 (0)