FContainer.AddChild C# (CSharp) Метод

AddChild() публичный Метод

public AddChild ( FNode, node ) : void
node FNode,
Результат void
    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.stage = _stage;
                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.HandleFacetsChanged();
        }
    }

Usage Example

Пример #1
0
    public void setupMenu()
    {
        FContainer menuSelector = new FContainer();

        menuSelector.x = Futile.screen.width * 0.3f;
        menuSelector.y = -Futile.screen.height * 0.2f;

        selector.color  = tone1;
        selector.height = 48;
        selector.width  = Futile.screen.width * 2;
        menuSelector.AddChild(selector);

        FButton toAdd;

        toAdd = addButton("Play");
        menuSelector.AddChild(toAdd);
        toAdd    = addButton("Options");
        toAdd.y -= 48;
        menuSelector.AddChild(toAdd);
        toAdd    = addButton("Exit");
        toAdd.y -= 96;
        menuSelector.AddChild(toAdd);

        this.AddChild(menuSelector);
        menuElements[0].label.color = tone2;
    }
All Usage Examples Of FContainer::AddChild