From 52db34152f6059d0e29b766f30713785e6fb974a Mon Sep 17 00:00:00 2001 From: VisualSj Date: Tue, 22 Dec 2015 15:54:55 +0800 Subject: [PATCH] Fixed a bug about empty component added --- cocos2d/core/CCNode.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 3f706b3ee1..6b07bcf772 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -467,7 +467,12 @@ var Node = cc.Class({ if (! (component instanceof cc.Component) && CC_EDITOR) { cc.error('Sorry, the component of entity "%s" which with an index of %s is corrupted! It has been removed.\nSee DevTools for details.', this.name, c); console.log('Corrupted component value:', component); - this._removeComponent(component); + if (component) { + this._removeComponent(component); + } + else { + this._components.splice(c, 1); + } --c; --originCount; }