Comunidad de diseño web y desarrollo en internet online

aceleracio y desaceleracio con programacion

Citar            
MensajeEscrito el 15 Jul 2007 09:25 pm
Buenas,

Tengo una función para crear un movimiento de desaceleración tal que:

// Función con aceleracion-desaceleracion
mover = function (este, alli_x, alli_y, velocidad) {
eval(este).onEnterFrame = function() {
eval(este)._y = eval(este)._y+(alli_y-eval(este)._y)/velocidad;
eval(este)._x = eval(este)._x+(alli_x-eval(este)._x)/velocidad;
};
};

Para luego desde un botón hacer la llamada
// Llamada a la funcion
mover("cuadrado_mc", 450, cuadrado_mc._y, 5);

La cuestión es que no consigo crear una función igual pero con el efecto inverso, es decir, de aceleración.
Y como no sou muy bueno en matemáticas :) A ver si me podéis echar una mano-.

Por mateo

3 de clabLevel



 

firefox
Citar            
MensajeEscrito el 15 Jul 2007 09:35 pm
Mira esto lo ise hace un tiempo atras (Trabajado Sobre El MC asique pasa el codigo a Frame)

Código :

onClipEvent (load) {
vel=15//Velocidad maxima
i=1//Velocidad inicial Derecha
r=1//Velocidad inicial Izquierda
}
onClipEvent (enterFrame) {
p=1*Math.pow(i,2)
if((Key.isDown(Key.RIGHT))&&(p<vel)){
this._x+=p
i+=0.2
}
else
if(i>0){
this._x+=p
i-=0.2
}
}
onClipEvent (enterFrame) {
p=1*Math.pow(r,2)
if((Key.isDown(Key.LEFT))&&(p<vel)){
this._x-=p
r+=0.2
}
else
if(r>0){
this._x-=p
r-=0.2
}
}

Por JaLeRu

Claber

1913 de clabLevel

7 tutoriales

Genero:Masculino  

Existo

firefox
Citar            
MensajeEscrito el 15 Jul 2007 09:37 pm
Esta seria la traduccion al Frame:

Código :

mc.onLoad=function(){
vel=15//Velocidad maxima
i=1//Velocidad inicial Derecha
r=1//Velocidad inicial Izquierda
}
this.onEnterFrame=function() {
p=1*Math.pow(i,2)
if((Key.isDown(Key.RIGHT))&&(p<vel)){
this._x+=p
i+=0.2
}
else
if(i>0){
this._x+=p
i-=0.2
}
}
this.onEnterFrame=function() {
p=1*Math.pow(r,2)
if((Key.isDown(Key.LEFT))&&(p<vel)){
this._x-=p
r+=0.2
}
else
if(r>0){
this._x-=p
r-=0.2
}

}

Aun no lo pruebo.... Pero creo que deberia funcionar

Por JaLeRu

Claber

1913 de clabLevel

7 tutoriales

Genero:Masculino  

Existo

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.