Many thanks for your reply, I would love to be able to have the balls collide with each other, unfortunately my scripting is not that great, any suggestion on how I might make this happen. Each ball has three frames of script as seen below. Any help on this would be sincerely appreciated !
************ Frame 1 ********************
//Set the bounds
bounds = new Object();
bounds.left = 50;
bounds.right = 730;
bounds.top = 100;
bounds.bottom = 488;
//Set initial speed vector
speed = new Object();
speed.x = 10;
speed.y = 10;
//Set friction to act on ball
friction = .98;
//Set boolean for drag property
drag = false;
//Gravity and Friction toggle variables
friction_t = true;
gravity_t = true;
************** Frame 2 ***********************
if(drag) {
//If the ball is being dragged, recalculate it's speed
if(old_x <> this._x || old_y <> this._y) {
speed.x = (this._x - old_x) / 4;
speed.y = (this._y - old_y) / 4;
}
old_x = this._x;
old_y = this._y;
} else {
//move ball
this._x += speed.x;
this._y += speed.y;
//Check bounds
if(this._x < bounds.left) {
speed.x *= -1;
this._x = bounds.left;
} else if(this._x > bounds.right) {
speed.x *= -1;
this._x = bounds.right;
} else if(this._y < bounds.top) {
speed.y *= -1;
this._y = bounds.top;
} else if(this._y > bounds.bottom) {
speed.y *= -1;
this._y = bounds.bottom;
}
if(friction_t) {
//apply friction to horizontal plain
speed.x *= friction;
//apply y friction if gravity is off
if(!gravity_t){
speed.y *= friction;
}
}
if(gravity_t) {
//apply gravity to vertical plain
if(speed.y > 0){
speed.y *= 1.3;
} else if(speed.y < 0){
speed.y *= .68;
}
if((speed.y < 2) && (speed.y > -2) && (this._y < (bounds.bottom - 2))) {
speed.y = 2;
}
if((speed.y == 2) && (this._y > (bounds.bottom - 3))) {
speed.y = 0;
this._y = bounds.bottom;
}
}
}
********************* Frame 3 *******************
Many thanks for your reply, I would love to be able to have the balls collide with each other, unfortunately my scripting is not that great, any suggestion on how I might make this happen. Each ball has three frames of script as seen below. Any help on this would be sincerely appreciated !
************ Frame 1 ********************
//Set the bounds
bounds = new Object();
bounds.left = 50;
bounds.right = 730;
bounds.top = 100;
bounds.bottom = 488;
//Set initial speed vector
speed = new Object();
speed.x = 10;
speed.y = 10;
//Set friction to act on ball
friction = .98;
//Set boolean for drag property
drag = false;
//Gravity and Friction toggle variables
friction_t = true;
gravity_t = true;
************** Frame 2 ***********************
if(drag) {
//If the ball is being dragged, recalculate it's speed
if(old_x <> this._x || old_y <> this._y) {
speed.x = (this._x - old_x) / 4;
speed.y = (this._y - old_y) / 4;
}
old_x = this._x;
old_y = this._y;
} else {
//move ball
this._x += speed.x;
this._y += speed.y;
//Check bounds
if(this._x < bounds.left) {
speed.x *= -1;
this._x = bounds.left;
} else if(this._x > bounds.right) {
speed.x *= -1;
this._x = bounds.right;
} else if(this._y < bounds.top) {
speed.y *= -1;
this._y = bounds.top;
} else if(this._y > bounds.bottom) {
speed.y *= -1;
this._y = bounds.bottom;
}
if(friction_t) {
//apply friction to horizontal plain
speed.x *= friction;
//apply y friction if gravity is off
if(!gravity_t){
speed.y *= friction;
}
}
if(gravity_t) {
//apply gravity to vertical plain
if(speed.y > 0){
speed.y *= 1.3;
} else if(speed.y < 0){
speed.y *= .68;
}
if((speed.y < 2) && (speed.y > -2) && (this._y < (bounds.bottom - 2))) {
speed.y = 2;
}
if((speed.y == 2) && (this._y > (bounds.bottom - 3))) {
speed.y = 0;
this._y = bounds.bottom;
}
}
}
********************* Frame 3 *******************
Many thanks for your reply, I would love to be able to have the balls collide with each other, unfortunately my scripting is not that great, any suggestion on how I might make this happen. Each ball has three frames of script as seen below. Any help on this would be sincerely appreciated !
************ Frame 1 ********************
//Set the bounds
bounds = new Object();
bounds.left = 50;
bounds.right = 730;
bounds.top = 100;
bounds.bottom = 488;
//Set initial speed vector
speed = new Object();
speed.x = 10;
speed.y = 10;
//Set friction to act on ball
friction = .98;
//Set boolean for drag property
drag = false;
//Gravity and Friction toggle variables
friction_t = true;
gravity_t = true;
************** Frame 2 ***********************
if(drag) {
//If the ball is being dragged, recalculate it's speed
if(old_x <> this._x || old_y <> this._y) {
speed.x = (this._x - old_x) / 4;
speed.y = (this._y - old_y) / 4;
}
old_x = this._x;
old_y = this._y;
} else {
//move ball
this._x += speed.x;
this._y += speed.y;
//Check bounds
if(this._x < bounds.left) {
speed.x *= -1;
this._x = bounds.left;
} else if(this._x > bounds.right) {
speed.x *= -1;
this._x = bounds.right;
} else if(this._y < bounds.top) {
speed.y *= -1;
this._y = bounds.top;
} else if(this._y > bounds.bottom) {
speed.y *= -1;
this._y = bounds.bottom;
}
if(friction_t) {
//apply friction to horizontal plain
speed.x *= friction;
//apply y friction if gravity is off
if(!gravity_t){
speed.y *= friction;
}
}
if(gravity_t) {
//apply gravity to vertical plain
if(speed.y > 0){
speed.y *= 1.3;
} else if(speed.y < 0){
speed.y *= .68;
}
if((speed.y < 2) && (speed.y > -2) && (this._y < (bounds.bottom - 2))) {
speed.y = 2;
}
if((speed.y == 2) && (this._y > (bounds.bottom - 3))) {
speed.y = 0;
this._y = bounds.bottom;
}
}
}
********************* Frame 3 *******************
Many thanks for your reply, I would love to be able to have the balls collide with each other, unfortunately my scripting is not that great, any suggestion on how I might make this happen. Each ball has three frames of script as seen below. Any help on this would be sincerely appreciated !
************ Frame 1 ********************
//Set the bounds
bounds = new Object();
bounds.left = 50;
bounds.right = 730;
bounds.top = 100;
bounds.bottom = 488;
//Set initial speed vector
speed = new Object();
speed.x = 10;
speed.y = 10;
//Set friction to act on ball
friction = .98;
//Set boolean for drag property
drag = false;
//Gravity and Friction toggle variables
friction_t = true;
gravity_t = true;
************** Frame 2 ***********************
if(drag) {
//If the ball is being dragged, recalculate it's speed
if(old_x <> this._x || old_y <> this._y) {
speed.x = (this._x - old_x) / 4;
speed.y = (this._y - old_y) / 4;
}
old_x = this._x;
old_y = this._y;
} else {
//move ball
this._x += speed.x;
this._y += speed.y;
//Check bounds
if(this._x < bounds.left) {
speed.x *= -1;
this._x = bounds.left;
} else if(this._x > bounds.right) {
speed.x *= -1;
this._x = bounds.right;
} else if(this._y < bounds.top) {
speed.y *= -1;
this._y = bounds.top;
} else if(this._y > bounds.bottom) {
speed.y *= -1;
this._y = bounds.bottom;
}
if(friction_t) {
//apply friction to horizontal plain
speed.x *= friction;
//apply y friction if gravity is off
if(!gravity_t){
speed.y *= friction;
}
}
if(gravity_t) {
//apply gravity to vertical plain
if(speed.y > 0){
speed.y *= 1.3;
} else if(speed.y < 0){
speed.y *= .68;
}
if((speed.y < 2) && (speed.y > -2) && (this._y < (bounds.bottom - 2))) {
speed.y = 2;
}
if((speed.y == 2) && (this._y > (bounds.bottom - 3))) {
speed.y = 0;
this._y = bounds.bottom;
}
}
}
********************* Frame 3 *******************
gotoAndPlay(this._currentframe-1);