estoy intentando hacer un ejercicio que consiste en que 2 pelotas reboten en un escenario y entre si y que cada vez que lo hagan vayan desacelerando hasta que se queden paradas, pero no lo acabo de conseguir. Dejo el código para si pueden me echen una mano y el ejercicio Gracias.
[code]bola1.onRelease = function(){
velocidad_bola1X = 5
velocidad_bola2X = 5
velocidad_bola1Y = 5
velocidad_bola2Y = 5
desacelerar = 0.7
onEnterFrame = function(){
bola1._x += velocidad_bola1X
bola2._x += velocidad_bola2X
bola1._y += velocidad_bola1Y
bola2._y += velocidad_bola2Y
if(bola1._x >=(550-bola1._width/2)){
bola1._x = 550-bola1._width/2
velocidad_bola1X *= -desacelerar
}
else if(bola1._x <=(0+bola1._width/2)){
bola1._x = 0+bola1._width/2
velocidad_bola1X *= -desacelerar
}
if(bola1._y<=(0+bola1._width/2)){
bola1._y = 0+bola1._width/2
velocidad_bola1Y *= -desacelerar
}
else if(bola1._y >=(400-bola1._width/2)){
bola1._y = 400-bola1._width/2
velocidad_bola1Y *= -desacelerar
}
if(bola2._x >=(550-bola2._width/2)){
bola2._x = 550-bola2._width/2
velocidad_bola2X *= -desacelerar
}
else if(bola2._x <=(0+bola2._width/2)){
bola2._x = 0+bola2._width/2
velocidad_bola2X *= -desacelerar
}
if(bola2._y<=(0+bola2._width/2)){
bola2._y = 0+bola2._width/2
velocidad_bola2Y *= -desacelerar
}
else if(bola2._y >=(400-bola2._width/2)){
bola2._y = 400-bola2._width/2
velocidad_bola2Y *= -desacelerar
}
colisionX = bola1.hitTest(bola2)
if(colisionX == true){
velocidad_bola1X *=-0.8
velocidad_bola2X *=-0.8
velocidad_bola1Y *=0.8
velocidad_bola2Y *=0.8
}
}
}[/flash]