Stage.addChild C# (CSharp) Method

addChild() public method

public addChild ( DisplayObject child ) : void
child DisplayObject
return void
    public override void addChild(DisplayObject child)
    {
        if(_childList.IndexOf(child)!=-1){
            return;
        }
        if(child.parent!=null){
            child.parent.removeChild(child);
        }
        _childList.Add(child);
        child.stage			= this;
        child.parent		= this;
    }

Usage Example

Example #1
0
    void Activate()
    {
        if (GameObject.Find("Main Camera").GetComponent<MovieClipOverlayCameraBehaviour>() == null)
        {
            return;
        }
        PauseStage = Camera.main.GetComponent<MovieClipOverlayCameraBehaviour>().stage;

        BackGround = new MovieClip("swf/PauseField.swf:FadeBackground");
        BackGround.gotoAndStop(1);
        BackGround.x = Screen.width / 2;
        BackGround.y = Screen.height / 2;
        BackGround.scaleX = (float)Screen.width / 2048;
        BackGround.scaleY = BackGround.scaleX;
        PauseStage.addChild(BackGround);

        for (int i = 0; i < ButtonCount; i++)
        {
            Buttons[i] = new MovieClip("swf/PauseField.swf:PauseField");
            Buttons[i].gotoAndStop(1);
            Buttons[i].x = Screen.width/2;
            Buttons[i].y = Screen.height * 0.3f + (float)Screen.height/2048 * 220 * i;
            Buttons[i].scaleX = (float)Screen.width / 2048;
            Buttons[i].scaleY = Buttons[i].scaleX;

            MenuFields[i] = Buttons[i].getChildByName<TextField>("Text");
            MenuFields[i].text = names[i];

            PauseStage.addChild(Buttons[i]);
        }

        Buttons[0].addEventListener(MouseEvent.CLICK, Resume);
        Buttons[1].addEventListener(MouseEvent.CLICK, Reload);
        Buttons[3].addEventListener(MouseEvent.CLICK, Quit);
    }
All Usage Examples Of Stage::addChild