J’ai edit et je voulais dire un bouton ^^
EDIT : PS merci pour ta réponse déjà pour le Echap ça marche
Voilà ma classe et j’aimerais rajouter un bouton comme Minecraft mais je le veux tout jaune et voilà
package fr.altiscraft.altiscraft.common; import java.util.ArrayList; import java.util.List; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.ResourceLocation; public class GuiATM extends GuiScreen { int guiWidth = 250; int guiHeight = 250; protected List buttonList = new ArrayList(); private GuiTextField text; int i = this.height / 4 + 48; public void initGui() { super.initGui(); this.buttonList.add(new GuiButton(0, 0, 0, 50, 20, "Pierre")); } @Override public void drawScreen(int x, int y, float ticks) { int guix = (width - guiWidth) / 2; int guiy = (height - guiHeight) / 2; mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/Fond.png")); drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight); GL11.glColor4f(1, 1, 1, 1); fontRendererObj.drawString("ATM", guix + 120, guiy - 10, 0xFFFF00); super.drawScreen(x, y, ticks); } protected void actionPerformed(GuiButton button) { if (button.id == 0) { } } protected void keyTyped(char par1, int par2) { } public void updateScreen() { super.updateScreen(); } @Override public boolean doesGuiPauseGame() { return false; } }
J’ai fais des recherches et des tests mais rien
EDIT : En fesant Echap on ne peut pas quitter mon GUI comment résoudre ?
J’ai pas compris l’histoire du bloc. Pour le bouton échap : tu as ré-écris la fonction keyTiped donc soit tu l’enlèves, soit tu rajoutes dedans super.keyTiped();.
J’ai edit et je voulais dire un bouton ^^
EDIT : PS merci pour ta réponse déjà pour le Echap ça marche
Tu override la fonction draw du button et tu bind une autre texture.
Ou tu peux faire un GL11.glColor4f pour colorer la texture en jaune.
Juste c’est normal qu’avec ça :
@Override public void initGui() { super.initGui(); this.buttonList.add(new GuiButton(0, 0, 0, 50, 20, "Pierre")); }
Il n’y a aucun bouton ?
Perso, j’utilise ça:
buttonList.add(tradeButton = new GuiButton(0, guiX + 8, guiY + 12 + 5, 98, 20, label));
et ça fonctionne parfaitement.
EDIT: mets le super.initGui(); après le add
Merci de ton aide et sinon j’ai ça :
@Override public void initGui() { this.buttonList.add(new GuiButton(0, 0, 0, 50, 20, "Pierre")); super.initGui(); }
et ça ne marche toujours pas et pour ton code tu mets quoi comme arguments ?
Avec les coordonnées que tu as mit ton bouton devrait apparaitre tout en haut à gauche.
Bas je peux envoyer un screen à part si les coordonnées sont codés de façon à ce que l’extrémité bas droite est tout en haut à gauche et là il n’est pas sur l’écran mais marche…
Voilà ma classe complète :
package fr.altiscraft.altiscraft.common; import java.util.ArrayList; import java.util.List; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.ResourceLocation; public class GuiATM extends GuiScreen { int guiWidth = 250; int guiHeight = 250; protected List buttonList = new ArrayList(); private GuiTextField text; int i = this.height / 4 + 48; @Override public void drawScreen(int x, int y, float ticks) { int guix = (width - guiWidth) / 2; int guiy = (height - guiHeight) / 2; mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/Fond.png")); drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight); GL11.glColor4f(1, 1, 1, 1); fontRendererObj.drawString("ATM", guix + 120, guiy - 10, 0xFFFF00); super.drawScreen(x, y, ticks); } protected void actionPerformed(GuiButton button) { if (button.id == 0) { } } @Override public boolean doesGuiPauseGame() { return false; } @Override public void initGui() { this.buttonList.add(new GuiButton(0, 0, 0, 50, 20, "Pierre")); super.initGui(); } }
Surement car ton button est en dehors du gui.
Mets comme coordonnées this.guiLeft et this.guiTop
this.guiLeft, this.guiTop ne marche pas comme ce n’est pas un GUI container comment le convertir ?
Essayes de mettre ton bouton au centre pour voir s’il s’affiche.
Toujours rien avec la position de mon texte…
package fr.altiscraft.altiscraft.common; import java.util.ArrayList; import java.util.List; import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.ResourceLocation; public class GuiATM extends GuiScreen { int guiWidth = 140; int guiHeight = 180; protected List buttonList = new ArrayList(); private GuiTextField text; int i = this.height / 4 + 48; @Override public void drawScreen(int x, int y, float ticks) { int guix = (width - guiWidth) / 2; int guiy = (height - guiHeight) / 2; mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/Fond.png")); drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight); GL11.glColor4f(1, 1, 1, 1); fontRendererObj.drawString("Gestion du Compte Bancaire", guix + 2, guiy + 5, 0xFFFFFF); super.drawScreen(x, y, ticks); } protected void actionPerformed(GuiButton button) { if (button.id == 0) { } } @Override public boolean doesGuiPauseGame() { return false; } @Override public void initGui() { int guix = (width - guiWidth) / 2; int guiy = (height - guiHeight) / 2; this.buttonList.add(new GuiButton(0, guix + 2, guiy + 5, 50, 20, "Cobble")); super.initGui(); } }
Toujours rien avec la position de mon texte…
package fr.altiscraft.altiscraft.common; import java.util.ArrayList; import java.util.List; import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.ResourceLocation; public class GuiATM extends GuiScreen { int guiWidth = 140; int guiHeight = 180; protected List buttonList = new ArrayList(); private GuiTextField text; int i = this.height / 4 + 48; @Override public void drawScreen(int x, int y, float ticks) { int guix = (width - guiWidth) / 2; int guiy = (height - guiHeight) / 2; mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/Fond.png")); drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight); GL11.glColor4f(1, 1, 1, 1); fontRendererObj.drawString("Gestion du Compte Bancaire", guix + 2, guiy + 5, 0xFFFFFF); super.drawScreen(x, y, ticks); } protected void actionPerformed(GuiButton button) { if (button.id == 0) { } } @Override public boolean doesGuiPauseGame() { return false; } @Override public void initGui() { int guix = (width - guiWidth) / 2; int guiy = (height - guiHeight) / 2; this.buttonList.add(new GuiButton(0, guix + 2, guiy + 5, 50, 20, "Cobble")); super.initGui(); } }
Mets le GL11.glColor4f(1, 1, 1, 1); avant la fonction drawTexturedModalRect pour voir ?
Aucun changement…
Aucune idée dans ce cas
tu n’as pas un code d’un GUI avec un bouton ? à part un container…
Non, pas sur mes projets publics.