Exemplo n.º 1
0
 /** Get a Spring instance and set it to the given parameters. */
 public Spring getSpring(ForceItem f1, ForceItem f2, float k, float length) {
   if (springs.size() > 0) {
     Spring s = (Spring) springs.remove(springs.size() - 1);
     s.item1 = f1;
     s.item2 = f2;
     s.coeff = k;
     s.length = length;
     return s;
   } else {
     return new Spring(f1, f2, k, length);
   }
 }
Exemplo n.º 2
0
 /** Reclaim a Spring into the object pool. */
 public void reclaim(Spring s) {
   s.item1 = null;
   s.item2 = null;
   if (springs.size() < maxSprings) springs.add(s);
 }