본문 바로가기
Game/Minecraft

마인크래프트 서버 접속기 만들기[3]

by ryush00 2013. 3. 30.


   안녕하세요. 말똥이입니다.



2013/03/30 - [마인크래프트/개발] - 마인크래프트 서버 접속기 만들기[1]


2013/03/30 - [마인크래프트/개발] - 마인크래프트 서버 접속기 만들기[2]



 이번에는 저번 글에 이어

버튼의 위치와 크기를 바꿔보겠습니다.




저 다시접속버튼대신 메인메뉴버튼과 다시접속을 둘다 만들어보는겁니다.

ㄱㄱ



버튼에 대해 알려면 GuiButton.java에 들어가보면 됩니다.


    public GuiButton(int par1, int par2, int par3, int par4, int par5, String par6Str)

    {

        this.width = 200;

        this.height = 20;

        this.enabled = true;

        this.drawButton = true;

        this.id = par1;

        this.xPosition = par2;

        this.yPosition = par3;

        this.width = par4;

        this.height = par5;

        this.displayString = par6Str;

    }


이렇게 구성되어있네요.


첫번째의 this.width는 this.width의 기본값설정

두번째 this.height도 기본값설정..

3번째는.. 글세요. 저것도 기본값인데..


어쨌든


        this.width = 200;

        this.height = 20;

        this.enabled = true;

        this.drawButton = true;


예네 모두가 기본값입니다.

그아래부터


        this.id = par1;


이건 고유번호


        this.xPosition = par2;

        this.yPosition = par3;


이건 위치(좌표)



        this.width = par4;

        this.height = par5;


이건 크기


        this.displayString = par6Str;


이건 뜨는 내용입니다.


위치를 바꿀거니까 두번째를 수정해야겠네요.


아까 GuiDisconnected.java에서 


        this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, "다시 접속")); 아래에


        this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "메인 메뉴로"));



를 추가해주세요.


그리고 

    protected void actionPerformed(GuiButton par1GuiButton)

    {

        if (par1GuiButton.id == 0)

        {

            //this.mc.displayGuiScreen(this.field_98095_n);

        //this.mc.displayGuiScreen(new GuiConnecting(this, this.mc, new ServerData("계피서버", "mc.ryush00.com")));

        this.mc.displayGuiScreen(new GuiMainMenu());

        }

    }



예를


    protected void actionPerformed(GuiButton par1GuiButton)

    {

        if (par1GuiButton.id == 0)

        {

            //this.mc.displayGuiScreen(this.field_98095_n);

        //this.mc.displayGuiScreen(new GuiConnecting(this, this.mc, new ServerData("계피서버", "mc.ryush00.com")));

        this.mc.displayGuiScreen(new GuiMainMenu());

        }

        if (par1GuiButton.id == 1)

        {

        this.mc.displayGuiScreen(new GuiConnecting(this, this.mc, new ServerData("서버이름", "서버주소")));

        }

    }

이걸 추가해주세요.




그런데 지금 현재는 두 버튼의 위치가 같죠?

실행하면 겹칠게 뻔하죠..


높이를 바꾸려면 par3을 수정해주면 되겠죠?


3번째네요.


this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "메인 메뉴로"));


이곳을 바꾸면 됩니다. 여기서 어떻게든 노가다하든 어떻게하든 위치를 수정해보면



        this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "메인 메뉴로"));

        this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 - 12 , "다시 접속"));


+- 차이네요..

이렇게 됩니다.





우왕 굳


To Be Contine




*1.5.2는 너무 오래되었을 뿐더러, 질문하셔도 답변해 드리기 어렵습니다. 개인적 일기라 생각하여 주세요.

댓글