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 & HelpProcessing Implementations › What must i do in this java-script
Page Index Toggle Pages: 1
What must i do in this java-script (Read 1369 times)
What must i do in this java-script
Mar 7th, 2009, 9:29pm
 
What must i do in this java-script to display an egg?

Egg e1;
void setup()
{
 size(400, 400);
 smooth();
}
class Egg {
 float x, y; // X-coordinate, y-coordinate
 float angle; // Used to define the tilt
 float scalar; // Height of the egg
 // Constructor
 Egg(int xpos, int ypos, float s) {
   x = xpos;
   y = ypos;
   scalar = s / 100.0;
 }
 void display() {
   noStroke();
   fill(255);
   translate(x, y);
   scale(scalar);
   beginShape();
   vertex(0, -100);
   bezierVertex(25, -100, 40, -65, 40, -40);
   bezierVertex(40, -15, 25, 0, 0, 0);
   bezierVertex(-25, 0, -40, -15, -40, -40);
   bezierVertex(-40, -65, -25, -100, 0, -100);
   endShape();
 }
}
void draw()
{
 e1.display();
 background(0);
e1 = new Egg(66, 132, 66);
}

there comes an error : "NullPointerExeption"
and a grey window, that i can only close with Taskmamager
Re: What must i do in this java-script
Reply #1 - Mar 7th, 2009, 10:24pm
 
If that's like in classical Processing, the problem is that you initialize your egg after using it...
You should move the e1 = new Egg() cal in the setup().
Re: What must i do in this java-script
Reply #2 - Mar 10th, 2009, 8:06pm
 
PhiLho  wrote on Mar 7th, 2009, 10:24pm:
If that's like in classical Processing, the problem is that you initialize your egg after using it...
You should move the e1 = new Egg() cal in the setup().


Thanks, that´s it!
Page Index Toggle Pages: 1