mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-04 10:32:39 +08:00
Merge pull request #2084 from knoxHuang/v1.7
fix texture2D _contentSize undefined err
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user