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 › Unexpected Tokens
Page Index Toggle Pages: 1
Unexpected Tokens? (Read 457 times)
Unexpected Tokens?
Dec 14th, 2009, 7:54pm
 
Hi, I'm still relatively new to processing, and I was wondering why there are so many unexpected tokens within my program please?  I know when it gives that error, it either means, I'm missing a bracket or semicolon, but neither of those are the problem here (that I can see anyways).  And if there's an error, it is usually located above the line it highlights.  The line that it highlights is void setup() {, but I'm sure the program probably has more than just this error  Embarrassed

Here's the code and a brief description of what I am trying to do:

/**
* A new line of API feed is retrieved from Twitter - wishes category
* each time a star is clicked on.  I want the stars to be positioned
* randomly all over the screen mimicking a starry night where one
* hopes to find a shooting star that will grant his or her wishes.
*
* flo
**/


PImage star;
PFont bookAntiqua;
bookAntiqua = loadFont("BookAntiqua.ttf");

XMLElement xml;

Star[] stars = new Star[100];  //100 stars in total
//int index = 0;

void setup(){
 size(800, 600);
 background(0);
 myFont = createFont(bookAntiqua, 12);
 textFont(myFont);


 //Load RSS Feed
 String url = "http: // search. twitter. com/search? q=wish";
 xml = new XMLElement(this, "http:/ /search. twitter. com/ search?q=wish");
 println(xml);

 star = loadImage("star3.png");
}

void draw() {
 background(0);
 
 for (int i = 0; i < index; i++) { //what exactly does this do?
   stars[i].render();
 }
 
}

void mousePressed() {
 //if your mouse is in the centre of the image, then that image
 //will be mouseOvered
 boolean mouseOver() {   //booleans return true/false

   float xDist = abs(xpos + size/2 - mouseX);
   float yDist = abs(ypos + size/2 - mouseY);
   //if mouse is over heart (within the size/2) then say true
   if(sqrt(sq(yDist) + sq(xDist)) < size/2 ) {
     return true;
   }
   else {
     return false;
   }
 }
}

void addStar () {

 String message = "(content.getChild("Subject")).getContent()";

}

// clicking on star method
void mouseReleased() {
 if(capturedStar != null) {
   if(capturedStar.clicked) { //when clicked
     capturedStar.clicked = false;
     text(message, width+3, height+5);

   }
   else if(!capturedStar.clicked) { //not clicked
     capturedStar.clicked = true;

   }
 }

}


***********
Thank you for any suggestions as to why and where the errors are.  :]

Re: Unexpected Tokens?
Reply #1 - Dec 14th, 2009, 11:25pm
 
This line is in the wrong place:

bookAntiqua = loadFont("BookAntiqua.ttf");

It should be inside the setup.
Page Index Toggle Pages: 1