Need Action Script Help.

Want to say something off topic? Something that has nothing to do with Trek? Post it here.
posted on November 22nd, 2006, 2:13 am
Last edited by ewm90 on November 22nd, 2006, 2:18 am, edited 1 time in total.
I am trying to get a refletion efect with action srcipt. I have one object that falls to one pont on the stage as it should but when I chage speedy =
Code: Select all
speedy + gravity;
to
Code: Select all
speedy - gravity;
it gos flaying off the stage and wont retern the same problom hapinds when I chage
Code: Select all
gravity = 2;
to
Code: Select all
 gravity < 2;
same problom... How do I redefine the Y axes so both objects will meet?

Code: Select all
onClipEvent (load) {
// gravity is what I called g in the tutorial. The
// higher g the harder the ball will fall.
// gravity = 0 can be set, as an experiment, but
// it will in fact create a "zero gravity" effect
// gravity < 0 will create an inverted gravity effect
gravity = 2;

// This sets the _y position of the floor
floor = -320;
floorx1 = 0;
floorx2 = -90;

// Bounce is a number < 1 but close to 1
// The closer to 1, the higher the ball will bounce
bounce = 0.92;

// We set the speed of the ball when it is released.
speedx = 0;
speedy = 0;
}

onClipEvent (enterFrame) {
if (pressing) {

// if we are pressing
// drag the object
startDrag (this,true);
// calculate the speed
speedx = this._x - x3;
speedy = this._y - y1;
// set a new reference point
x4 = this._x;
y7 = this._y;

} else {

stopDrag ();
speedy = speedy + gravity;

this._x += speedx/5;
this._y += speedy/5;

if (this._y > floor) {
this._y = floor;
speedy *= -bounce;
}
if (this._x < floorx1) {
this._x = floorx1;
speedx *= -bounce;
}
if (this._x > floorx2) {
this._x = floorx2;
speedx *= -bounce;
}
}
}
Reply

Who is online

Users browsing this forum: No registered users and 7 guests

cron