We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Interactive program syntax
Page Index Toggle Pages: 1
Interactive program syntax? (Read 302 times)
Interactive program syntax?
Jul 21st, 2008, 6:57pm
 
Does this setup make sense to create a game that will lead you to other pages, i.e. pressing the imageButton yes will lead the player to another "screen".


PFont font;
ImageButtons button;

String output1= "Are you ready to play?";

boolean reset= false;
boolean splash=true;
boolean finish=false;
boolean buttonYesOver= true;
boolean buttonNoOver= false;


void setup()
{
size (400, 400);
background (200);
PImage Yes= loadImage("Yes.png");
PImage No= loadImage("No.png");
button = new ImageButtons(buttonYes, buttonNo)
}

void draw()
{

font = loadFont("Courier-30.vlw");
textFont(font);
textSize(28);
fill(51);
text(output1, 120, 100);


}

class Button
{
 boolean over = false || true;
 boolean pressed = false || true;
 
 void pressed() {
   if(over && mousePressed) {
     pressed = true;
   } else {
     pressed = false;
   }
 }
}

 boolean overYes() {
   if (mouseX >= 130 && mouseX <= 170 &&
   mouseY >=130 && mouseY <= 170) {
     return true;
   } else {
     return false;
   }
   
 }
}
Re: Interactive program syntax?
Reply #1 - Jul 21st, 2008, 9:25pm
 
These two lines should be in setup() :
Code:
font = loadFont("Courier-30.vlw");
textFont(font);

This line makes no sense since your code contains no ImageButtons class, and there's no such class in Processing API.
Code:
button = new ImageButtons(buttonYes, buttonNo); 


I guess you want to reuse the ImageButton example of the Learning section to create something like a dialog box with two yes/no buttons. You can't do that this way. You need two different image buttons, and you need to specify the appropriate arguments in the constructor. See the answer to your other post :
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1216658893
Page Index Toggle Pages: 1