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 & HelpOther Libraries › Traer Spring.class syntax
Page Index Toggle Pages: 1
Traer Spring.class syntax ? (Read 992 times)
Traer Spring.class syntax ?
Sep 7th, 2007, 11:52pm
 
Hello, I'm fairly new to processing, been playing with it off/ on for about a year but just started some serious stuff in the last month or so.

I've been wondering about some of these methods in the Traer.physics library (which is super sweet, I must say) that have to do with turning on and off Springs and Attractions.

Basically I can't figure out the syntax-- how do you reference the particular spring you want to turn off, call it by particle name? That hasn't worked for me yet... As far as I could see there was only one very simple instance of any of these in the examples, and it was the particle.kill() method which kills a particle 'forever.'

I unpacked the jar and looked at the the Spring.class code but that didn't help me much either:


Code:


/* Constructors */
public Spring(traer/physics/Particle, traer/physics/Particle, float, float, float) {
}


/* Methods */
public final void turnOff() {
}

public final void turnOn() {
}

public final boolean isOn() {
}

public final boolean isOff() {
}


Any Idears?
Re: Traer Spring.class syntax ?
Reply #1 - Sep 8th, 2007, 12:16am
 
Well, you can either keep a reference ot the spring:

Code:
Spring s=pm.makeSpring(part1,part2,0.1,.5,20);
//...
s.turnOff();


Or if you've only got the particles that make up the ends stored...

Code:
for(int i=0;i<pm.numberOfSprings();i++)
{
Spring s=pm.getSpring(i);
if((s.getOneEnd()==part1 || s.getOneEnd()==part2) && (s.getTheOtherEnd()==part1 || s.getTheOtherEnd()==part2))
{
s.turnOff();
}
}
Re: Traer Spring.class syntax ?
Reply #2 - Sep 8th, 2007, 1:00am
 
Aahh, I'll give that a go. One of my problems is that I'm using arrayList's so referencing specific springs is a pain.
But I'll report back.

Thanks!
Tim
Re: Traer Spring.class syntax ?
Reply #3 - Sep 19th, 2007, 6:57pm
 
thanks again John, this worked great!
Page Index Toggle Pages: 1