|
55 | 55 |
|
56 | 56 | if (!this._bakeSprite){
|
57 | 57 | this._bakeSprite = new cc.BakeSprite();
|
58 |
| - this._bakeSprite._parent = this._node; |
| 58 | + this._bakeSprite.setAnchorPoint(0,0); |
59 | 59 | }
|
60 | 60 | }
|
61 | 61 | };
|
|
93 | 93 | var ctx = bakeContext.getContext();
|
94 | 94 | locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height);
|
95 | 95 |
|
96 |
| - var anchor = locBakeSprite.getAnchorPointInPoints(), locPos = node._position; |
97 |
| - if(node._ignoreAnchorPointForPosition){ |
98 |
| - //bakeContext.translate(0 - boundingBox.x + locPos.x, boundingBox.height + boundingBox.y - locPos.y); |
99 |
| - bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y ); |
100 |
| - //reset the bake sprite's position |
101 |
| - locBakeSprite.setPosition(anchor.x + boundingBox.x - locPos.x, anchor.y + boundingBox.y - locPos.y); |
102 |
| - } else { |
103 |
| - var selfAnchor = this.getAnchorPointInPoints(); |
104 |
| - var selfPos = {x: locPos.x - selfAnchor.x, y: locPos.y - selfAnchor.y}; |
105 |
| - //bakeContext.translate(0 - boundingBox.x + selfPos.x, boundingBox.height + boundingBox.y - selfPos.y); |
106 |
| - bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y); |
107 |
| - locBakeSprite.setPosition(anchor.x + boundingBox.x - selfPos.x, anchor.y + boundingBox.y - selfPos.y); |
108 |
| - } |
| 96 | + bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y ); |
| 97 | + locBakeSprite.setPosition(boundingBox.x, boundingBox.y); |
109 | 98 |
|
110 | 99 | //visit for canvas
|
111 | 100 | node.sortAllChildren();
|
|
114 | 103 | children[i].visit(this);
|
115 | 104 | }
|
116 | 105 | cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId);
|
117 |
| - locBakeSprite.transform(this); //because bake sprite's position was changed at rendering. |
| 106 | + locBakeSprite.transform(); //because bake sprite's position was changed at rendering. |
118 | 107 | this._cacheDirty = false;
|
119 | 108 | }
|
120 | 109 | };
|
|
234 | 223 | var bakeContext = locBakeSprite.getCacheContext();
|
235 | 224 | var ctx = bakeContext.getContext();
|
236 | 225 | locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height);
|
237 |
| - var anchor = locBakeSprite.getAnchorPointInPoints(), locPos = node._position; |
238 |
| - if(node._ignoreAnchorPointForPosition){ |
239 |
| - //bakeContext.translate(0 - boundingBox.x + locPos.x, boundingBox.height + boundingBox.y - locPos.y); |
240 |
| - bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y ); |
241 |
| - //reset the bake sprite's position |
242 |
| - locBakeSprite.setPosition(anchor.x + boundingBox.x - locPos.x, anchor.y + boundingBox.y - locPos.y); |
243 |
| - } else { |
244 |
| - var selfAnchor = this.getAnchorPointInPoints(); |
245 |
| - var selfPos = {x: locPos.x - selfAnchor.x, y: locPos.y - selfAnchor.y}; |
246 |
| - //bakeContext.translate(0 - boundingBox.x + selfPos.x, boundingBox.height + boundingBox.y - selfPos.y); |
247 |
| - bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y); |
248 |
| - locBakeSprite.setPosition(anchor.x + boundingBox.x - selfPos.x, anchor.y + boundingBox.y - selfPos.y); |
249 |
| - } |
| 226 | + |
| 227 | + bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y ); |
| 228 | + locBakeSprite.setPosition(boundingBox.x, boundingBox.y); |
250 | 229 |
|
251 | 230 | var child;
|
252 | 231 | cc.renderer._turnToCacheMode(this.__instanceId);
|
|
268 | 247 | } else
|
269 | 248 | cc.renderer.pushRenderCommand(this);
|
270 | 249 | cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId);
|
271 |
| - locBakeSprite.transform(this); |
| 250 | + locBakeSprite.transform(); |
272 | 251 | this._cacheDirty = false;
|
273 | 252 | }
|
274 | 253 | };
|
|
0 commit comments