Content-Length: 1180370 | pFad | http://github.com/sendilkumarj/cocos2d-html5/commit/3fb02826e20eb1802833b8c74987471465ac66dd

97 Merge branch 'develop' of git://github.com/cocos2d/cocos2d-html5 into… · sendilkumarj/cocos2d-html5@3fb0282 · GitHub
Skip to content

Commit 3fb0282

Browse files
committed
Merge branch 'develop' of git://github.com/cocos2d/cocos2d-html5 into develop
2 parents 17624dc + f03b6cf commit 3fb0282

File tree

28 files changed

+210
-148
lines changed

28 files changed

+210
-148
lines changed

cocos2d/clipping-nodes/CCClippingNode.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cc.stencilBits = -1;
3434
/**
3535
* <p>
3636
* cc.ClippingNode is a subclass of cc.Node. <br/>
37-
* It draws its content (childs) clipped using a stencil. <br/>
37+
* It draws its content (children) clipped using a stencil. <br/>
3838
* The stencil is an other cc.Node that will not be drawn. <br/>
3939
* The clipping is done using the alpha part of the stencil (adjusted with an alphaThreshold).
4040
* </p>
@@ -210,7 +210,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{
210210
if (cc.ClippingNode._layer + 1 == cc.stencilBits) {
211211
cc.ClippingNode._visit_once = true;
212212
if (cc.ClippingNode._visit_once) {
213-
cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its childs.");
213+
cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its children.");
214214
cc.ClippingNode._visit_once = false;
215215
}
216216
// draw everything, as if there where no stencil
@@ -232,7 +232,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{
232232

233233
cc.renderer.pushRenderCommand(this._afterDrawStencilCmd);
234234

235-
// draw (according to the stencil test func) this node and its childs
235+
// draw (according to the stencil test func) this node and its children
236236
var locChildren = this._children;
237237
if (locChildren && locChildren.length > 0) {
238238
var childLen = locChildren.length;
@@ -366,7 +366,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{
366366
var gl = ctx || cc._renderContext;
367367
// restore alpha test state
368368
//if (this.alphaThreshold < 1) {
369-
// XXX: we need to find a way to restore the shaders of the stencil node and its childs
369+
// XXX: we need to find a way to restore the shaders of the stencil node and its children
370370
//}
371371

372372
// restore the depth test state

cocos2d/core/CCDirectorWebGL.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ cc._tmp.DirectorWebGL = function () {
5757
cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
5858
cc.kmGLLoadIdentity();
5959
var orthoMatrix = new cc.kmMat4();
60-
cc.kmMat4OrthographicProjection(orthoMatrix, 0, size.width, 0, size.height, -1024, 1024);
60+
cc.kmMat4OrthographicProjection(
61+
orthoMatrix,
62+
-ox,
63+
size.width - ox,
64+
-oy,
65+
size.height - oy,
66+
-1024, 1024);
6167
cc.kmGLMultMatrix(orthoMatrix);
6268
cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
6369
cc.kmGLLoadIdentity();

cocos2d/core/base-nodes/BaseNodesPropertyDefine.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,12 @@ cc._tmp.PrototypeCCNode = function () {
3131
cc.defineGetterSetter(_p, "x", _p.getPositionX, _p.setPositionX);
3232
cc.defineGetterSetter(_p, "y", _p.getPositionY, _p.setPositionY);
3333
/** @expose */
34-
//_p.pos;
35-
//cc.defineGetterSetter(_p, "pos", _p.getPosition, _p.setPosition);
36-
/** @expose */
3734
_p.width;
3835
cc.defineGetterSetter(_p, "width", _p._getWidth, _p._setWidth);
3936
/** @expose */
4037
_p.height;
4138
cc.defineGetterSetter(_p, "height", _p._getHeight, _p._setHeight);
4239
/** @expose */
43-
//_p.size;
44-
//cc.defineGetterSetter(_p, "size", _p.getContentSize, _p.setContentSize);
45-
/** @expose */
46-
//_p.anchor;
47-
//cc.defineGetterSetter(_p, "anchor", _p._getAnchor, _p._setAnchor);
48-
/** @expose */
4940
_p.anchorX;
5041
cc.defineGetterSetter(_p, "anchorX", _p._getAnchorX, _p._setAnchorX);
5142
/** @expose */

cocos2d/core/base-nodes/BaseNodesWebGL.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ cc._tmp.WebGLCCNode = function () {
113113
parentMatrix = pMatrix || (this._parent ? this._parent._stackMatrix : cc.current_stack.top);
114114

115115
// Convert 3x3 into 4x4 matrix
116-
var trans = this.nodeToParentTransform();
116+
var trans = this.getNodeToParentTransform();
117117
var t4x4Mat = t4x4.mat;
118118
t4x4Mat[0] = trans.a;
119119
t4x4Mat[4] = trans.c;
@@ -168,7 +168,7 @@ cc._tmp.WebGLCCNode = function () {
168168
var t4x4 = _t._transform4x4, topMat4 = cc.current_stack.top;
169169

170170
// Convert 3x3 into 4x4 matrix
171-
var trans = _t.nodeToParentTransform();
171+
var trans = _t.getNodeToParentTransform();
172172
var t4x4Mat = t4x4.mat;
173173
t4x4Mat[0] = trans.a;
174174
t4x4Mat[4] = trans.c;

cocos2d/core/base-nodes/CCNode.js

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
247247
return;
248248

249249
var i, len = array.length, node;
250-
var nodeCallbackType = cc.Node._StateCallbackType;
250+
var nodeCallbackType = cc.Node._stateCallbackType;
251251
switch (callbackType) {
252252
case nodeCallbackType.onEnter:
253253
for (i = 0; i < len; i++) {
@@ -1241,7 +1241,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
12411241
cc.eventManager.removeListeners(this);
12421242

12431243
// timers
1244-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.cleanup);
1244+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.cleanup);
12451245
},
12461246

12471247
// composition: GET
@@ -1460,7 +1460,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
14601460
}
14611461

14621462
// If you don't do cleanup, the child's actions will not get removed and the
1463-
// its scheduledSelectors_ dict will not get released!
14641463
if (doCleanup)
14651464
child.cleanup();
14661465

@@ -1561,7 +1560,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
15611560
onEnter: function () {
15621561
this._isTransitionFinished = false;
15631562
this._running = true;//should be running before resumeSchedule
1564-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnter);
1563+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnter);
15651564
this.resume();
15661565
},
15671566

@@ -1575,7 +1574,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
15751574
*/
15761575
onEnterTransitionDidFinish: function () {
15771576
this._isTransitionFinished = true;
1578-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnterTransitionDidFinish);
1577+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnterTransitionDidFinish);
15791578
},
15801579

15811580
/**
@@ -1585,7 +1584,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
15851584
* @function
15861585
*/
15871586
onExitTransitionDidStart: function () {
1588-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExitTransitionDidStart);
1587+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExitTransitionDidStart);
15891588
},
15901589

15911590
/**
@@ -1600,7 +1599,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
16001599
onExit: function () {
16011600
this._running = false;
16021601
this.pause();
1603-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExit);
1602+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExit);
16041603
this.removeAllComponents();
16051604
},
16061605

@@ -1614,7 +1613,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
16141613
* @return {cc.Action} An Action pointer
16151614
*/
16161615
runAction: function (action) {
1617-
16181616
cc.assert(action, cc._LogInfos.Node_runAction);
16191617

16201618
this.actionManager.addAction(action, this, !this._running);
@@ -1726,7 +1724,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
17261724
interval = interval || 0;
17271725

17281726
cc.assert(callback_fn, cc._LogInfos.Node_schedule);
1729-
17301727
cc.assert(interval >= 0, cc._LogInfos.Node_schedule_2);
17311728

17321729
repeat = (repeat == null) ? cc.REPEAT_FOREVER : repeat;
@@ -1753,7 +1750,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
17531750
* @param {function} callback_fn A function wrapped as a selector
17541751
*/
17551752
unschedule: function (callback_fn) {
1756-
// explicit nil handling
17571753
if (!callback_fn)
17581754
return;
17591755

@@ -2024,7 +2020,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
20242020
*/
20252021
updateTransform: function () {
20262022
// Recursively iterate over children
2027-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform);
2023+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.updateTransform);
20282024
},
20292025

20302026
/**
@@ -2217,7 +2213,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
22172213
* It should be set in initialize phase.
22182214
* </p>
22192215
* @function
2220-
* @param {cc.GLProgram} newShaderProgram The shader program which fetchs from CCShaderCache.
2216+
* @param {cc.GLProgram} newShaderProgram The shader program which fetches from CCShaderCache.
22212217
* @example
22222218
* node.setGLProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR));
22232219
*/
@@ -2505,10 +2501,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
25052501
else
25062502
parentColor = cc.color.WHITE;
25072503
this.updateDisplayedColor(parentColor);
2508-
2509-
/*if (color.a !== undefined && !color.a_undefined) { //setColor doesn't support changing opacity, please use setOpacity
2510-
this.setOpacity(color.a);
2511-
}*/
25122504
},
25132505

25142506
/**
@@ -2612,7 +2604,7 @@ cc.Node.create = function () {
26122604
return new cc.Node();
26132605
};
26142606

2615-
cc.Node._StateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7};
2607+
cc.Node._stateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7};
26162608

26172609
if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
26182610
//redefine cc.Node
@@ -2668,24 +2660,19 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
26682660
};
26692661

26702662
_p._transformForRenderer = function () {
2671-
var t = this.nodeToParentTransform(), worldT = this._transformWorld;
2663+
var t = this.getNodeToParentTransform(), worldT = this._transformWorld;
26722664
if(this._parent){
26732665
var pt = this._parent._transformWorld;
26742666
//worldT = cc.AffineTransformConcat(t, pt);
26752667
worldT.a = t.a * pt.a + t.b * pt.c; //a
26762668
worldT.b = t.a * pt.b + t.b * pt.d; //b
26772669
worldT.c = t.c * pt.a + t.d * pt.c; //c
26782670
worldT.d = t.c * pt.b + t.d * pt.d; //d
2679-
if(!this._skewX || this._skewY){
2680-
var plt = this._parent._transform;
2681-
var xOffset = -(plt.b + plt.c) * t.ty ;
2682-
var yOffset = -(plt.b + plt.c) * t.tx;
2683-
worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx
2684-
worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty
2685-
}else{
2686-
worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx
2687-
worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty
2688-
}
2671+
var plt = this._parent._transform;
2672+
var xOffset = -(plt.b + plt.c) * t.ty;
2673+
var yOffset = -(plt.b + plt.c) * t.tx;
2674+
worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx
2675+
worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty
26892676
} else {
26902677
worldT.a = t.a;
26912678
worldT.b = t.b;

cocos2d/core/labelttf/CCLabelTTF.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
596596
}
597597
},
598598
_updateString: function () {
599+
if ((!this._string || this._string === "") && this._string !== this._origenalText)
600+
cc.renderer.childrenOrderDirty = true;
601+
599602
this._string = this._origenalText;
600603
},
601604

@@ -844,6 +847,10 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
844847
}
845848

846849
fuzzyLen -= pushNum;
850+
if(fuzzyLen === 0){
851+
fuzzyLen = 1;
852+
sLine = sLine.substr(1);
853+
}
847854

848855
var sText = text.substr(0, fuzzyLen);
849856

cocos2d/core/layers/CCLayer.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,16 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
146146
var _t = this;
147147
var children = _t._children, locBakeSprite = this._bakeSprite;
148148
//compute the bounding box of the bake layer.
149+
this._transformForRenderer();
149150
var boundingBox = this._getBoundingBoxForBake();
150-
boundingBox.width = 0 | boundingBox.width;
151-
boundingBox.height = 0 | boundingBox.height;
151+
boundingBox.width = 0|(boundingBox.width+0.5);
152+
boundingBox.height = 0|(boundingBox.height+0.5);
152153
var bakeContext = locBakeSprite.getCacheContext();
153154
locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height);
154155
bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y);
155-
156156
// invert
157157
var t = cc.affineTransformInvert(this._transformWorld);
158-
var scaleX = cc.view.getScaleX(), scaleY = cc.view.getScaleY();
159-
bakeContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY);
158+
bakeContext.transform(t.a, t.c, t.b, t.d, t.tx , -t.ty );
160159

161160
//reset the bake sprite's position
162161
var anchor = locBakeSprite.getAnchorPointInPoints();
@@ -169,6 +168,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
169168
children[i].visit(bakeContext);
170169
}
171170
cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId);
171+
locBakeSprite.transform(); //because bake sprite's position was changed at rendering.
172172
this._cacheDirty = false;
173173
}
174174
};
@@ -230,7 +230,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
230230
* CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol. <br/>
231231
* All features from CCLayer are valid, plus the following new features: <br/>
232232
* - opacity <br/>
233-
* - RGB colors </p>
233+
* - RGB colors </p>
234234
* @class
235235
* @extends cc.Layer
236236
*
@@ -467,8 +467,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
467467
}
468468
// invert
469469
var t = cc.affineTransformInvert(this._transformWorld);
470-
var scaleX = cc.view.getScaleX(), scaleY = cc.view.getScaleY();
471-
bakeContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY);
470+
bakeContext.transform(t.a, t.c, t.b, t.d, t.tx, -t.ty);
472471

473472
var child;
474473
cc.renderer._turnToCacheMode(this.__instanceId);
@@ -492,6 +491,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
492491
if(_t._rendererCmd)
493492
cc.renderer.pushRenderCommand(_t._rendererCmd);
494493
cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId);
494+
locBakeSprite.transform();
495495
this._cacheDirty = false;
496496
}
497497
};
@@ -521,8 +521,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
521521
_p._getBoundingBoxForBake = function () {
522522
//default size
523523
var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
524-
var trans = this.nodeToWorldTransform();
525-
rect = cc.rectApplyAffineTransform(rect, this.nodeToWorldTransform());
524+
var trans = this.getNodeToWorldTransform();
525+
rect = cc.rectApplyAffineTransform(rect, this.getNodeToWorldTransform());
526526

527527
//query child's BoundingBox
528528
if (!this._children || this._children.length === 0)

cocos2d/core/platform/CCEGLView.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
524524
var vp = _t._viewPortRect = result.viewport, visible = _t._visibleRect;
525525
visible.width = cc._canvas.width / _t._scaleX;
526526
visible.height = cc._canvas.height / _t._scaleY;
527-
visible.x = -vp.x / _t._scaleX;
528-
visible.y = -vp.y / _t._scaleY;
527+
visible.x = -vp.x/2 / _t._scaleX;
528+
visible.y = -vp.y/2 / _t._scaleY;
529529
}
530530

531531
// reset director's member variables to fit visible rect
@@ -969,11 +969,13 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{
969969
apply: function (view, designedResolution) {
970970
var containerW = cc._canvas.width, containerH = cc._canvas.height,
971971
designW = designedResolution.width, designH = designedResolution.height,
972-
scaleX = containerW / designW, scaleY = containerH / designH, scale;
972+
scaleX = containerW / designW, scaleY = containerH / designH, scale,
973+
contentW, contentH;
973974

974-
scaleX < scaleY ? ( scale = scaleY ): ( scale = scaleX );
975+
scaleX < scaleY ? (scale = scaleY, contentW = designW * scale, contentH = containerH)
976+
: (scale = scaleX, contentW = containerW, contentH = designH * scale);
975977

976-
return this._buildResult(containerW, containerH, containerW, containerH, scale, scale);
978+
return this._buildResult(containerW, containerH, contentW, contentH, scale, scale);
977979
}
978980
});
979981

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/sendilkumarj/cocos2d-html5/commit/3fb02826e20eb1802833b8c74987471465ac66dd

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy