TheDubsteppingNinja Posted October 24, 2015 Share Posted October 24, 2015 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? :'( Quote Link to comment Share on other sites More sharing options...
Flenix Posted October 24, 2015 Share Posted October 24, 2015 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. Quote http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats Link to comment Share on other sites More sharing options...
TheDubsteppingNinja Posted October 24, 2015 Author Share Posted October 24, 2015 Yes, the gui is taking up the full size of the png Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.