Jump to content

[SOLVED][1.8] Centering GUI Texture


TheDubsteppingNinja

Recommended Posts

In a class that extends GuiContainer, I used this to center my texture....

	int x = (this.width-textureWidth)/2;//my texture is a 256x256 texture therefore, textureWidth and textureHeight = 256
int y = (this.height-textureHeight)/2;

 

and this to place it.....

		this.drawTexturedModalRect(x, y, 0, 0, guiWidth, guiHeight);

 

registering the guihandler in preinit like this

		NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

 

But for some reason the texture is being placed at the top left corner at the screen with 3 quarters of the texture being cut off. The center of the texture is being placed at 0, 0 instead of the center of the screen like intended. Yes, I'm new to Forge, but I am not a complete idiot, I used the debugger to figure out that "this.height" and "this.width" equals 0, therefore placing the gui at -128,-128.

 

So why is this happening and can someone tell me how to fix it??? Is the container affecting it? Is it where I'm registering the guihandler?

 

Link to comment
Share on other sites

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.