Merge pull request #710 from jareguo/master

make sizeProvider error more clear
This commit is contained in:
Wang Nan
2016-05-23 11:24:21 +08:00
7 changed files with 30 additions and 16 deletions
+9 -2
View File
@@ -149,8 +149,15 @@ var Canvas = cc.Class({
if ( !this.node._sizeProvider ) {
this.node._sizeProvider = designResolutionWrapper;
}
else {
cc.error('CCCanvas: Node can only have one size.');
else if (CC_DEV) {
var renderer = this.node.getComponent(cc._RendererUnderSG);
if (renderer) {
cc.error('Should not add Canvas to a node which already contains a renderer component (%s).',
cc.js.getClassName(renderer));
}
else {
cc.error('Should not add Canvas to a node which size is already used by its other component.');
}
}
cc.director.on(cc.Director.EVENT_BEFORE_VISIT, this.alignWithScreen, this);
+1 -3
View File
@@ -400,9 +400,7 @@ var Label = cc.Class({
if (this.overflow === Overflow.NONE) {
this.node.setContentSize(this._sgNode.getContentSize());
}
if ( !this.node._sizeProvider ) {
this.node._sizeProvider = this._sgNode;
}
this._registSizeProvider();
}
}
});
+1 -4
View File
@@ -57,10 +57,7 @@ var RendererUnderSG = cc.Class({
// and remember to hide the sgNode if component.enabledInHierarchy is false.
__preload: function () {
this._initSgNode();
var sgNode = this._sgNode;
if ( !this.node._sizeProvider ) {
this.node._sizeProvider = sgNode;
}
this._registSizeProvider();
this._appendSgNode(this._sgNode);
},
+15
View File
@@ -79,6 +79,21 @@ var SGComponent = cc.Class({
* @private
*/
_removeSgNode: SceneGraphHelper.removeSgNode,
_registSizeProvider: function () {
if ( !this.node._sizeProvider ) {
this.node._sizeProvider = this._sgNode;
}
else if (CC_DEV) {
var name = cc.js.getClassName(this);
if (this.node.getComponent(cc.Canvas)) {
cc.error('Should not add renderer component (%s) to a Canvas node.', name);
}
else {
cc.error('Should not add %s to a node which size is already used by its other component.', name);
}
}
}
});
cc._SGComponent = module.exports = SGComponent;
+1 -3
View File
@@ -61,9 +61,7 @@ var TiledLayer = cc.Class({
if ( !this.enabledInHierarchy ) {
sgNode.setVisible(false);
}
if ( !this.node._sizeProvider ) {
this.node._sizeProvider = sgNode;
}
this._registSizeProvider();
var node = this.node;
sgNode.setAnchorPoint(node.getAnchorPoint());
},
+1 -3
View File
@@ -815,9 +815,7 @@ sp.Skeleton = cc.Class({
sgNode.setContentSize(0, 0); // restore content size
self._initSgNode();
self._appendSgNode(sgNode);
if ( !self.node._sizeProvider ) {
self.node._sizeProvider = sgNode;
}
self._registSizeProvider();
}
if (CC_EDITOR) {
+2 -1
View File
@@ -33,6 +33,7 @@
"require-dir": "0.3.0",
"vinyl": "1.1.0",
"vinyl-buffer": "1.0.0",
"vinyl-source-stream": "1.0.0"
"vinyl-source-stream": "1.0.0",
"watchify": "^3.7.0"
}
}