small fix

This commit is contained in:
yinkaile
2017-12-19 10:26:10 +08:00
parent 186910d426
commit e30ce09da4
6 changed files with 17 additions and 32 deletions
+6 -13
View File
@@ -350,8 +350,12 @@ var Label = cc.Class({
this._bmFontOriginalSize = value.fontSize;
}
if (this._renderData) {
RenderData.free(this._renderData);
this._renderData = null;
}
this._fontAtlas = null;
this._material = null;
this._clearData();
this._activateMaterial();
this._updateRenderData();
},
@@ -424,19 +428,8 @@ var Label = cc.Class({
},
onEnable: function () {
this._super();
this._activateMaterial();
this.node._renderComponent = this;
},
onDisable: function () {
this._clearData();
this.node._renderComponent = null;
},
_clearData: function () {
RenderData.free(this._renderData);
this._renderData = null;
this._fontData = null;
},
_activateMaterial: function () {
@@ -59,6 +59,9 @@ var RenderComponent = cc.Class({
onDisable () {
this.node._renderComponent = null;
},
onDestroy () {
if (this._renderData) {
RenderData.free(this._renderData);
this._renderData = null;
+1 -6
View File
@@ -222,13 +222,8 @@ var Graphics = cc.Class({
},
onEnable: function () {
this._super();
this._activateMaterial();
this.node._renderComponent = this;
},
onDisable: function () {
this.clear(true);
this.node._renderComponent = null;
},
_activateMaterial: function () {
@@ -101,7 +101,7 @@ let _contentSize = cc.size();
module.exports = {
createData (comp) {
return new RenderData();
return RenderData.alloc();
},
update (comp) {
@@ -515,7 +515,6 @@ module.exports = {
},
_shrinkLabelToContentSize (lambda) {
let fontData = comp._fontData;
let fontSize = _fontSize;
let originalLineHeight = _lineHeight;
let fontAtlas = _fontAtlas;
@@ -524,7 +523,7 @@ module.exports = {
let tempLetterDefinition = fontAtlas.cloneLetterDefinition();
let flag = true;
while (lambda(fontData)) {
while (lambda()) {
++i;
let newFontSize = fontSize - i;
@@ -542,7 +541,7 @@ module.exports = {
} else {
this._multilineTextWrapByChar();
}
this._computeAlignmentOffset(fontData);
this._computeAlignmentOffset();
}
_lineHeight = originalLineHeight;
@@ -42,7 +42,7 @@ let _isUnderline = false;
module.exports = {
createData (comp) {
let renderData = new RenderData();
let renderData = RenderData.alloc();
renderData.dataLength = 4;
renderData.vertexCount = 4;
+3 -8
View File
@@ -208,19 +208,14 @@ var MotionStreak = cc.Class({
},
onEnable: function () {
this._super();
this._activateMaterial();
this.node._renderComponent = this;
this._applyFadeTime();
},
onDisable: function () {
RenderData.free(this._renderData);
this._material = null;
this._renderData = null;
this.node._renderComponent = null;
},
_activateMaterial: function () {
if (this._material) return;
let url = this._texture;
let texture = cc.textureUtil.loadImage(url);
let material = renderer.materialUtil.get(url);