本文整理汇总了C#中FNode.HandleAddedToContainer方法的典型用法代码示例。如果您正苦于以下问题:C# FNode.HandleAddedToContainer方法的具体用法?C# FNode.HandleAddedToContainer怎么用?C# FNode.HandleAddedToContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FNode
的用法示例。
在下文中一共展示了FNode.HandleAddedToContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddChild
public void AddChild(FNode node)
{
int nodeIndex = _childNodes.IndexOf(node);
if(nodeIndex == -1) //add it if it's not a child
{
node.HandleAddedToContainer(this);
_childNodes.Add(node);
if(_isOnStage)
{
node.HandleAddedToStage();
}
}
else if(nodeIndex != _childNodes.Count-1) //if node is already a child, put it at the top of the children if it's not already
{
_childNodes.RemoveAt(nodeIndex);
_childNodes.Add(node);
if(_isOnStage) _stage.HandleQuadsChanged();
}
}
示例2: AddChildAtIndex
public void AddChildAtIndex(FNode node, int newIndex)
{
int nodeIndex = _childNodes.IndexOf(node);
if(newIndex > _childNodes.Count) //if it's past the end, make it at the end
{
newIndex = _childNodes.Count;
}
if(nodeIndex == newIndex) return; //if it's already at the right index, just leave it there
if(nodeIndex == -1) //add it if it's not a child
{
node.HandleAddedToContainer(this);
_childNodes.Insert(newIndex, node);
if(_isOnStage)
{
node.HandleAddedToStage();
}
}
else //if node is already a child, move it to the desired index
{
_childNodes.RemoveAt(nodeIndex);
if(nodeIndex < newIndex)
{
_childNodes.Insert(newIndex-1, node); //gotta subtract 1 to account for it moving in the order
}
else
{
_childNodes.Insert(newIndex, node);
}
if(_isOnStage) _stage.HandleQuadsChanged();
}
}