Jump to content

Recommended Posts

Posted

So I'm trying to experiment with GUI's and ran into a brick wall here.

 

public class test_GUIScreen extends GuiScreen
{

int guiWidth = 256; //image is a 256x256 png
int guiHeight = 256;

int guiX = (width-guiWidth)/2; //centering 
int guiY = (height-guiHeight)/2;

GuiButton Test; //unused buton

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
	GL11.glColor4f(1, 1, 1, 1);
	drawDefaultBackground();
	mc.renderEngine.bindTexture(new ResourceLocation("test", "textures/gui/testtex3.png"));
	this.drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);
	super.drawScreen(mouseX, mouseY, partialTicks);
}

@Override
public void initGui()
{
//		buttonList.clear();
//		buttonList.add(Test = new GuiButton(0, guiX+1, guiY+2, 30, 20, "Test"));
	super.initGui();
}

@Override
protected void actionPerformed(GuiButton Button) throws IOException
{
	switch(Button.id)
	{
		case 0:
		case 1:
		case 2:
	}
	super.actionPerformed(Button);
}

@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
	super.mouseClicked(mouseX, mouseY, mouseButton);
}


}

 

This code is making the texture appear in the top left corner of the screen but I need it in the center ???. Can someone please share their insight?  :'( 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.