Comunidad de diseño web y desarrollo en internet online

Movimiento Cursores Clip

Citar            
MensajeEscrito el 22 Dic 2008 09:50 pm
Un saludo primeramente.

Estoy creando un mini juego tipo Pacman. El clip que maneja el jugador deberá moverse mediante los cursores del teclado.

Código :

function mover() {
   if (Key.isDown(Key.LEFT)) {
      this._x -= 3;
      this.gotoAndStop(3);
   }
   if (Key.isDown(Key.RIGHT)) {
      this._x += 3;
      this.gotoAndStop(2);
   }
   if (Key.isDown(Key.UP)) {
      this._y -= 3;
      this.gotoAndStop(4);
   }
   if (Key.isDown(Key.DOWN)) {
      this._y += 3;
      this.gotoAndStop(5);
   }
}


El problema es que no logro indicar la acción de ir y parar al fotograma 1 al clip "pacman" cuando no hay ninguna tecla pulsada. Intuyo que es algo parecido a ésto:

Código :

function mover() {
   if (Key.isDown(Key.LEFT)) {
      this._x -= 3;
      this.gotoAndStop(3);
   }
   else {
      this.gotoAndStop (1)
   }
}


Este último código me funciona perfectamente. Pero no sé cómo aplicar el comando "else" a todos los condicionales a la vez.

Por FABRIC

6 de clabLevel



 

opera
Citar            
MensajeEscrito el 23 Dic 2008 12:07 am
utiliza else if

Código :

function mover() {
   if (Key.isDown(Key.LEFT)) {
      this._x -= 3;
      this.gotoAndStop(3);
   }else if (Key.isDown(Key.RIGHT)) {
      this._x += 3;
      this.gotoAndStop(2);
   }else if (Key.isDown(Key.UP)) {
      this._y -= 3;
      this.gotoAndStop(4);
   }else if (Key.isDown(Key.DOWN)) {
      this._y += 3;
      this.gotoAndStop(5);
   }else{
       this.gotoAndStop (1);
   }
}

Por gparis

112 de clabLevel



 

Uruguay

firefox

 

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