i got sound using the action. but i cannot off it.
how to make it play once only?
the codes is this :
ZERO CONDITION:
[code]for (int i=0; i x[i] = xTop[i] + l*Math.sin(alpha[i]);
y[i] = yTop - l*Math.cos(alpha[i]);
}
// codes for calculation of zero condition based on length
double min = TOLERANCE;
for (int i=0; i for (int j=i+1; j double deltax = x[j]-x[i], deltay = y[j]-y[i];
double allowed = 2*radius;
double distance = deltax*deltax+deltay*deltay-allowed*allowed;
if (distance if (deltax*(omega[j]-omega[i])<0) {
// take action to take if loop checks for delatx*difference of angular velocities less than zero
ball1 = i; ball2 = j; min = distance;
// sound = true; // testing sound on
// }
// else { sound = false; //testing sound off
}
}
}
}
return min;[/code]
and i added the acion
ACTION
[code]double aux = omega[ball1]; // assign aux to omega[ball1]
omega[ball1] = omega[ball2]; // assign omega[ball1] = omega[ball2], because mass same so this will work
omega[ball2] = aux;
sound = true; // sound produced added by weelk but it is non stop why?[/code]