Font problem! "The field Component.font is not visible"

edited October 2013 in Questions about Code

Hi guys! I'm making a program that will help the user to choose a starter pokemon for each game (something like that). But the font doesn't work. Here's the code:

Boton []buttons;
int activeButtons=-1;

void drawButtons()
{
  for(int i=0; i<buttons.length;i++)
  {
    if(i==activeButtons)
       buttons[i].current=buttons[i].botSel;
    else
       buttons[i].current=buttons[i].botColor;

     buttons[i].dibujaBoton();
  }
}

void setup()
{
  size(800,750);
  background(255);
  font=createFont("Haettenschweiler-48",48);
  buttons = new Boton[3];
  buttons[0] = new Boton(width/2,700,color(240,128,7), color(200,32,60));
  buttons[1] = new Boton(width/3,700,color(123,221,240), color(13,78,190));
  buttons[2] = new Boton(2*width/3,700,color(135,234,36), color(11,200,23));
}

void draw()
{
  background(255);
  drawButtons();
  textFont(font,48);
  textAlign(CENTER,TOP);

  text("¿Qué pokemon inicial escojo?",width,height);

}

void mouseClicked()
{
  int x=mouseX;
  int y=mouseY;


}
Tagged:

Answers

  • Answer ✓

    You haven't posted all your code but the problem appears to be that you have not declared the font variable. Add the following line near the top of your code.

    PFont font;

  • now it works! thanks! I forgot about that.

  • Also either you use a VLW font, with the loadFont() function, or you use a font name from your system, with the createFont() function. Here, you mix them, so you probably just get the default font...

Sign In or Register to comment.