Comunidad de diseño web y desarrollo en internet online

HITTEST NO RESPONDE

Citar            
MensajeEscrito el 26 Ene 2010 12:32 pm
Cuando mi personaje avanza en horizontal y contacta con un obstáculo, el hitTest no se ejecuta y mi personaje no se detiene. Si alguien me puede ayudar, se lo agradeceré

Código ActionScript :

onClipEvent (load) {
   vx = 100;
   vy = 10;
}
onClipEvent (enterFrame) {
   
   
   if (Key.isDown(Key.UP)) {
      
      _y -= vy;
      while(_root.escenario.hitTest(_x,_y-_height/2,true)){
         _y++;
         
      }
      
   }
   if (Key.isDown(Key.DOWN)) {
      
      _y += vy;
      while(_root.escenario.hitTest(_x,_y+_height/2,true)){
         _y--;
         
      }
      
      
   }
   if (Key.isDown(Key.LEFT)) {
      
      _root.escenario._x+=vx;
      if(this._xscale>0){
         _xscale=-_xscale;
      }
      if(_root.escenario._x>= 0) {
         _root.escenario._x-=vx;
      }
      while(_root.escenario.hitTest(_x-_width/2,_y,true)){
         _x++;
         
      }
   }
   if (Key.isDown(Key.RIGHT)) {
      
      _root.escenario._x-=vx;
      
      if(this._xscale<0){
         _xscale=-_xscale;
      }
      if(_root.escenario._x+_root.escenario._width <= 1024) {
         _root.escenario._x+=vx;
      }
      while(_root.escenario.hitTest(_x+_width/2,_y,true)){
         _x--;
         
      }
   }
   
}


.

Por Aguileño

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Ene 2010 02:22 pm
Porque no se usa el while para eso, deberías usar un if.-

Saludos, Hernán . -

Por Hernán

BOFH

6148 de clabLevel

19 tutoriales
23 articulos

Genero:Masculino   REC Desarrollador de GAIA

Marketing & IT

firefox
Citar            
MensajeEscrito el 26 Ene 2010 02:41 pm

Hernán escribió:

Porque no se usa el while para eso, deberías usar un if.-

Saludos, Hernán . -


Aún con if tampoco se frena.

Código ActionScript :

   if (Key.isDown(Key.LEFT)) {
      
      _root.escenario._x+=vx;
      if(this._xscale>0){
         _xscale=-_xscale;
      }
      if(_root.escenario._x>= 0) {
         _root.escenario._x-=vx;
      }
      if(_root.escenario.hitTest(_x-_width/2,_y,true)){
         _x++;
         
      }
   }
   if (Key.isDown(Key.RIGHT)) {
      
      _root.escenario._x-=vx;
      
      if(this._xscale<0){
         _xscale=-_xscale;
      }
      if(_root.escenario._x+_root.escenario._width <= 1024) {
         _root.escenario._x+=vx;
      }
      if(_root.escenario.hitTest(_x+_width/2,_y,true)){
         _x--;
         
      }
   }
   
}

Por Aguileño

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 27 Ene 2010 12:55 am
No lo estas frenando:

Código ActionScript :

 _root.escenario._x+=vx; 


Saludos, Hernán . -

Por Hernán

BOFH

6148 de clabLevel

19 tutoriales
23 articulos

Genero:Masculino   REC Desarrollador de GAIA

Marketing & IT

firefox

 

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