Merge pull request #6214 from dumganhar/iss4744-set-dirty-for-node

closed #4744: EventDispatcher::setDirtyForNode doesn't consider node's children
This commit is contained in:
James Chen 2014-04-10 15:35:29 +08:00
commit 428cea061c
2 changed files with 12 additions and 3 deletions

View File

@ -1371,6 +1371,13 @@ void EventDispatcher::setDirtyForNode(Node* node)
{
_dirtyNodes.insert(node);
}
// Also set the dirty flag for node's children
const auto& children = node->getChildren();
for (const auto& child : children)
{
setDirtyForNode(child);
}
}
void EventDispatcher::setDirty(const EventListener::ListenerID& listenerID, DirtyFlag flag)

View File

@ -131,9 +131,11 @@ void TouchableSpriteTest::onEnter()
Point origin = Director::getInstance()->getVisibleOrigin();
Size size = Director::getInstance()->getVisibleSize();
auto containerForSprite1 = Node::create();
auto sprite1 = Sprite::create("Images/CyanSquare.png");
sprite1->setPosition(origin+Point(size.width/2, size.height/2) + Point(-80, 80));
addChild(sprite1, 10);
containerForSprite1->addChild(sprite1);
addChild(containerForSprite1, 10);
auto sprite2 = Sprite::create("Images/MagentaSquare.png");
sprite2->setPosition(origin+Point(size.width/2, size.height/2));
@ -174,11 +176,11 @@ void TouchableSpriteTest::onEnter()
target->setOpacity(255);
if (target == sprite2)
{
sprite1->setLocalZOrder(100);
containerForSprite1->setLocalZOrder(100);
}
else if(target == sprite1)
{
sprite1->setLocalZOrder(0);
containerForSprite1->setLocalZOrder(0);
}
};