Ver Mensaje Individual
  #4 (permalink)  
Antiguo 18/03/2010, 14:19
SilSal
 
Fecha de Ingreso: noviembre-2009
Mensajes: 39
Antigüedad: 14 años, 5 meses
Puntos: 2
Respuesta: Problema con hitTest

Gracias loncho_rojas por tu rápida respuesta!!
Pero con la función que me has comentado sucede el mismo problema que con las cordenadas. Nada, con las mismas. He ajustado el código al juego y sigue atravesando por las partes de arriba y de abajo del player el escenario.
Como también dijiste de poner aquí el código, aquí pongo el que utilizo:
Código:
velocidad = 7
margen = 15
margen1 = 20
onEnterFrame = function(){
	//Player1
	if (Key.isDown(Key.LEFT)){
		if (!this.fondo.hitTest(this.player._x-margen, this.player._y, true)) {
			this.player._x -= velocidad;
		}
	}else if (Key.isDown(Key.RIGHT)){
		if (!this.fondo.hitTest(this.player._x+margen, this.player._y, true)) {
			this.player._x += velocidad;
		}
	}
	else if (Key.isDown(Key.UP)){
		if (!this.fondo.hitTest(this.player._x, this.player._y-margen1, true)) {
			this.player._y -= velocidad;
		}
		
	}else if (Key.isDown(Key.DOWN)){
		if (!this.fondo.hitTest(this.player._x, this.player._y+margen1, true)) {
			this.player._y += velocidad;
		}
	}
}
player - Es el jugador
fondo - Es el laberinto, la pared


Espero que me podais ayudar.
¡¡¡¡¡¡Muchíiisimas gracias por tu respuesta, loncho_rojas!!!!!!!!!