Damaso
08-18-2003, 01:28 PM
I've been playing the swishmax demo I got from swishzone.com (http://www.swishzone.com/max_swi/demolisher.swf) called demolisher.swi. Any of you who are familiar with this maybe you can help me out. I'm no scripting intermediate nor expert, to this extent I teach myself by analyzing and experimenting. On the demolisher.swi, I wanted the "Ball" which is hanging from a "Hanger" to be steady (not swinging) when the movie starts. And when the "Hanger" is dragged and moved, the "Ball" should swing until it stop after a few swing, like a pendulum. I tried to chage some value and variable, but I still can't get it to work. :unsure:
Scene_1 code
function sqrt(val) {
i = 0;
x = 1;
while (i < 20) {
x = x - ((x * x - val) / (2 * x));
i += 1;
}
sqrt = (1000 * x) / 1000;
return sqrt;
}
Demolisher sprite code
onFrame (1) {
normalDist = 100;
elasticity = 0.7;
dampness = 0.00;
gravity = 0.1;
velX = 0.0;
velY = 0.0;
accelX = 0.0;
accelY = 0.0;
time = 5;
}
onFrame (2) {
distX = Hanger._X - Ball._X;
distY = Hanger._Y - Ball._Y;
currentDist = _root.sqrt(distX * distX + distY * distY);
accell = ((currentDist - normalDist) * elasticity) / normalDist;
accellX = accell * distX / currentDist;
accellY = ((accell * distY) / currentDist) + gravity;
velX += (accellX -(dampness * velX)) * time;
velY += (accellY -(dampness * velY)) * time;
trace(accellY);
trace(dampness * velY);
trace(time);
trace(velY);
Ball._X += velX * time;
Ball._Y += velY * time;
dot1._X = Hanger._X * 0.2 + Ball._X * 0.8;
dot1._Y = Hanger._Y * 0.2 + Ball._Y * 0.8;
dot2._X = Hanger._X * 0.4 + Ball._X * 0.6;
dot2._Y = Hanger._Y * 0.4 + Ball._Y * 0.6;
dot3._X = Hanger._X * 0.6 + Ball._X * 0.4;
dot3._Y = Hanger._Y * 0.6 + Ball._Y * 0.4;
dot4._X = Hanger._X * 0.8 + Ball._X * 0.2;
dot4._Y = Hanger._Y * 0.8 + Ball._Y * 0.2;
}
onFrame (3) {
gotoAndPlay(2);
}
Scene_1 code
function sqrt(val) {
i = 0;
x = 1;
while (i < 20) {
x = x - ((x * x - val) / (2 * x));
i += 1;
}
sqrt = (1000 * x) / 1000;
return sqrt;
}
Demolisher sprite code
onFrame (1) {
normalDist = 100;
elasticity = 0.7;
dampness = 0.00;
gravity = 0.1;
velX = 0.0;
velY = 0.0;
accelX = 0.0;
accelY = 0.0;
time = 5;
}
onFrame (2) {
distX = Hanger._X - Ball._X;
distY = Hanger._Y - Ball._Y;
currentDist = _root.sqrt(distX * distX + distY * distY);
accell = ((currentDist - normalDist) * elasticity) / normalDist;
accellX = accell * distX / currentDist;
accellY = ((accell * distY) / currentDist) + gravity;
velX += (accellX -(dampness * velX)) * time;
velY += (accellY -(dampness * velY)) * time;
trace(accellY);
trace(dampness * velY);
trace(time);
trace(velY);
Ball._X += velX * time;
Ball._Y += velY * time;
dot1._X = Hanger._X * 0.2 + Ball._X * 0.8;
dot1._Y = Hanger._Y * 0.2 + Ball._Y * 0.8;
dot2._X = Hanger._X * 0.4 + Ball._X * 0.6;
dot2._Y = Hanger._Y * 0.4 + Ball._Y * 0.6;
dot3._X = Hanger._X * 0.6 + Ball._X * 0.4;
dot3._Y = Hanger._Y * 0.6 + Ball._Y * 0.4;
dot4._X = Hanger._X * 0.8 + Ball._X * 0.2;
dot4._Y = Hanger._Y * 0.8 + Ball._Y * 0.2;
}
onFrame (3) {
gotoAndPlay(2);
}