Ver Mensaje Individual
  #8 (permalink)  
Antiguo 06/12/2008, 16:38
Avatar de yoseman
yoseman
 
Fecha de Ingreso: diciembre-2003
Ubicación: Alicante (Spain)
Mensajes: 471
Antigüedad: 20 años, 4 meses
Puntos: 5
Respuesta: Movimiento de objeto

ey hola,

Te paso dos ejemplos uno normal y uno con aceleración aunque ya te toca a tí optimizarlos supongo:

Código PHP:
init_x=100;
init_y=315;
max_y=227;
pelota._x=init_x;
pelota._y=init_y;

speed=-20

onEnterFrame = function() 
{     
    if(
Key.isDown(Key.UP) || speed>0
    {     
        if(
pelota._y<max_y || pelota._y>init_y
        { 
            
speed=-speed
        } 
        
pelota._y += speed
    } 

Código PHP:
init_x=100;
init_y=315;
max_y=227;
pelota._x=init_x;
pelota._y=init_y;
targety=init_y;
speed=-20

easing(pelota);
draw
function easing(m:MovieClip
{

    
m.onLoad = function() 
    {
        
        
this._x=init_x;
        
this._y=init_y;

    };
    
m.onEnterFrame = function() 
    {    
        if(
this._y<max_y)
        {
            
speed=-speed;
        }
        if(
Key.isDown(Key.UP)) 
        {    
            if(
speed<0)
            {
                
targety+=speed;
            }
        } 
        if(
speed>0)
        {
            
targety=init_y;            
            if(
this._y==targety)
                
speed=-speed;
        }
        
this._y += Math.ceil((targety-this._y)/2);
    };

Cualquier cosilla que surja encantado de ayudar.

Salu2 ;)
__________________
[+]
[+]