Posted October 24, 20159 yr 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? :'(
October 24, 20159 yr Is your GUI taking up the full size of the PNG file? The width/height you specify are purely the size of your ACTUAL GUI within the file. So, if you have a 256x256 file, but your drawn GUI is actually only 200x200, it's the 200x200 you need to specify. http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
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.