diff --git a/cocos2d/core/label/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js index 564c4a2c7b..acb90e6ad8 100644 --- a/cocos2d/core/label/CCSGLabel.js +++ b/cocos2d/core/label/CCSGLabel.js @@ -157,7 +157,7 @@ _ccsg.Label = _ccsg.Node.extend({ _ccsg.Node.prototype.ctor.call(this); this.setAnchorPoint(0.5, 0.5); - _ccsg.Node.prototype.setContentSize.call(this, 128, 128); + _ccsg.Node.prototype.setContentSize.call(this, 10, 10); this._blendFunc = cc.BlendFunc._alphaNonPremultiplied(); this._imageOffset = cc.p(0, 0); @@ -1270,8 +1270,6 @@ _ccsg.Label.pool = new JS.Pool(function (label) { label._fontHandle = ""; label._labelType = 0; label._resetBMFont(); - label._renderCmd._labelCanvas.width = 1; - label._renderCmd._labelCanvas.height = 1; label._renderCmd._texture.releaseTexture(); if (CC_DEV) { cc.assert(!label._parent, 'Recycling label\'s parent should be null!'); @@ -1294,7 +1292,7 @@ _ccsg.Label.pool.get = function (string, fontAsset) { label._position.x = 0; label._position.y = 0; label.setAnchorPoint(0.5, 0.5); - _ccsg.Node.prototype.setContentSize.call(label, 128, 128); + _ccsg.Node.prototype.setContentSize.call(label, 10, 10); if (isAsset) { label.setFontAsset(fontAsset); diff --git a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js index 3902eb1402..41db589143 100644 --- a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js +++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js @@ -399,7 +399,7 @@ }; proto._updateTexture = function() { - this._labelContext.clearRect(0, 0, this._labelCanvas.width, this._labelCanvas.height); + this._labelContext.clearRect(0, 0, this._canvasSize.width, this._canvasSize.height); this._labelContext.font = this._fontDesc; diff --git a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js index 81165fb542..fa3fc6f2f6 100644 --- a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js +++ b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js @@ -30,12 +30,14 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only) ****************************************************************************/ +var _sharedLabelCanvas; _ccsg.Label.WebGLRenderCmd = function(renderableObject){ this._rootCtor(renderableObject); this._needDraw = true; this._texture = new cc.Texture2D(); - this._labelCanvas = document.createElement("canvas"); + _sharedLabelCanvas = _sharedLabelCanvas || document.createElement('canvas'); + this._labelCanvas = _sharedLabelCanvas; this._texture.initWithElement(this._labelCanvas); this._labelContext = this._labelCanvas.getContext("2d"); @@ -65,8 +67,8 @@ proto.updateTransform = function (parentCmd) { this.originUpdateTransform(parentCmd); var node = this._node, - lx = 0, rx = this._labelCanvas.width, - by = 0, ty = this._labelCanvas.height, + lx = 0, rx = this._node.width, + by = 0, ty = this._node.height, wt = this._worldTransform; var vert = this._vertices;