mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Merge pull request #416 from jareguo/master
node should pause in ActionManager and EventManager by default
This commit is contained in:
@@ -1528,6 +1528,16 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
sgNode.setAnchorPoint(this._anchorPoint);
|
||||
sgNode.setVisible(this._active);
|
||||
sgNode.setColor(this._color);
|
||||
|
||||
// update ActionManager and EventManager because sgNode maybe changed
|
||||
if (this._activeInHierarchy) {
|
||||
cc.director.getActionManager().resumeTarget(this);
|
||||
cc.eventManager.resumeTarget(this);
|
||||
}
|
||||
else {
|
||||
cc.director.getActionManager().pauseTarget(this);
|
||||
cc.eventManager.pauseTarget(this);
|
||||
}
|
||||
},
|
||||
|
||||
// The deserializer for sgNode which will be called before components onLoad
|
||||
@@ -1538,6 +1548,12 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
this._parent._sgNode.addChild(this._sgNode);
|
||||
}
|
||||
|
||||
if ( !this._activeInHierarchy ) {
|
||||
// deactivate ActionManager and EventManager by default
|
||||
cc.director.getActionManager().pauseTarget(this);
|
||||
cc.eventManager.pauseTarget(this);
|
||||
}
|
||||
|
||||
var children = this._children;
|
||||
for (var i = 0, len = children.length; i < len; i++) {
|
||||
children[i]._onBatchCreated();
|
||||
|
||||
Reference in New Issue
Block a user