Esempio n. 1
0
void ContentLayer::replaceNode(Layout *node, Transition *enterTransition) {
	if (node && !node->isRunning()) {
		if (_nodes.empty()) {
			pushNode(node, enterTransition);
			return;
		}

		int zIndex = -(int)_nodes.size();
		for (auto node : _nodes) {
			node->setLocalZOrder(zIndex);
			zIndex ++;
		}

		_nodes.pushBack(node);

		node->ignoreAnchorPointForPosition(false);
		node->setAnchorPoint(Vec2(0.5f, 0.5f));
		node->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
		node->setContentSize(_contentSize);
		addChild(node, 1);

		for (auto &it : _nodes) {
			if (it != node) {
				it->onPopTransitionBegan(this, true);
			} else {
				it->onPush(this, true);
			}
		}

		if (enterTransition) {
			node->runAction(action::callback(enterTransition, [this, node] {
				for (auto &it : _nodes) {
					if (it != node) {
						it->onPop(this, true);
					} else {
						it->onPushTransitionEnded(this, true);
					}
				}
				replaceNodes();
			}));
		} else {
			for (auto &it : _nodes) {
				if (it != node) {
					it->onPop(this, true);
				} else {
					it->onPushTransitionEnded(this, true);
				}
			}
			replaceNodes();
		}

		_listener->setEnabled(true);
	}
}
Esempio n. 2
0
clique::clique(const std::vector<size_t> & unsorted_nodes)
{
    replaceNodes(unsorted_nodes);
}