Comunidad de diseño web y desarrollo en internet online

Duda con gravedad

Citar            
MensajeEscrito el 26 Nov 2006 08:04 pm
Buenas, tengo el siguiente script:

Código :

bola.onEnterFrame = mover;
g = 10;
var ensuelo:Boolean;
function mover() {
   if (this.x == undefined) {
      this.x = this._x;
      this.y = this._y;
   }
   if (terreno.hitTest(this.x, this.y, true)) {
      ensuelo = true;
   } else {
      this.y += g-0.8;
   }
   if (ensuelo) {
      if (Key.isDown(Key.RIGHT)) {
         this.x += 5;
         this.y = CoryA(this)+1;
      }
      if (Key.isDown(Key.LEFT)) {
         this.x -= 5;
         this.y = CoryA(this)+1;
      }
      this._x = this.x;
      this._y = this.y;
   }
   function CoryA(ins) {
      while (terreno.hitTest(ins.x, ins.y, true)) {
         ins.y--;
      }
      return ins.y;
   }
}


Lo que quiero hacer es que el personaje (bola), al darle a un boton (por ejemplo a la barra espacio del teclado), salte y que luego por el efecto de la gravedad, regrece al suelo, gracias de antemano. saludos

Por pepebello

19 de clabLevel



 

msie
Citar            
MensajeEscrito el 27 Nov 2006 01:11 pm

Por shogoki

355 de clabLevel

4 tutoriales

 

Venezuela

firefox

 

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