Merge pull request #2084 from knoxHuang/v1.7

fix texture2D _contentSize undefined err
This commit is contained in:
Jare Guo
2017-10-31 16:27:44 +08:00
committed by GitHub
2 changed files with 4 additions and 9 deletions
+3 -7
View File
@@ -472,7 +472,7 @@ _ccsg.Sprite = _ccsg.Node.extend({
var tex = cc.textureCache.getTextureForKey(filename);
if (!tex) {
tex = cc.textureCache.addImage(filename);
return this.initWithTexture(tex, rect || cc.rect(0, 0, tex._contentSize.width, tex._contentSize.height));
return this.initWithTexture(tex, rect || cc.rect(0, 0, tex.width, tex.height));
} else {
if (!rect) {
var size = tex.getContentSize();
@@ -693,12 +693,8 @@ _ccsg.Sprite = _ccsg.Node.extend({
this._changeRectWithTexture(texture);
},
_changeRectWithTexture: function(texture){
var contentSize = texture._contentSize;
var rect = cc.rect(
0, 0,
contentSize.width, contentSize.height
);
_changeRectWithTexture: function(texture) {
var rect = cc.rect(0, 0, texture.width, texture.height);
this.setTextureRect(rect);
},
@@ -50,8 +50,7 @@ proto._setTexture = function (texture) {
if (node._texture !== texture) {
node._textureLoaded = texture ? texture.loaded : false;
node._texture = texture;
var texSize = texture._contentSize;
var rect = cc.rect(0, 0, texSize.width, texSize.height);
var rect = cc.rect(0, 0, texture.width, texture.height);
node.setTextureRect(rect);
this._updateColor();
}