Comunidad de diseño web y desarrollo en internet online

hitTest

Citar            
MensajeEscrito el 17 Nov 2007 08:23 pm
hola se ke lo puse en otro post a esto pero no me contestaban... capaz ke pensaban ke ya estaba solucionado... pero casi... en fin el problema:

como seria la solucion para este codigo en AS2?
onClipEvent (load) {
velocidad = 7;
var personaje:MovieClip;
var pared:MovieClip;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= velocidad;
}
if (Key.isDown(Key.RIGHT)) {
_x += velocidad;
}
if (Key.isDown(Key.UP)) {
_y -=velocidad;
}
if (Key.isDown(Key.DOWN)) {
_y +=velocidad;
}
if (_root.pared.hitTest(_x, _y, true)) {
velocidad = 0;
}
}

el problema es ke al tocar la pared el personaje no se mueve mas para ningun lado :cry: asi ke bue... es una tontera para ustedes seguramente pero bue... a mi me cuesta horrores!

Por Engrampany

8 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 17 Nov 2007 10:18 pm
Prueba algo así:

Código :

onClipEvent (load) {
velocidad = 7;
var personaje:MovieClip;
var pared:MovieClip;
}
onClipEvent (enterFrame) {
contacto =!_root.pared.hitTest(_x, _y, true);
_x += velocidad*Key.isDown(Key.RIGHT)*contacto - velocidad*Key.isDown(Key.LEFT)*contacto;
_y += velocidad*Key.isDown(Key.DOWN)*contacto - velocidad*Key.isDown(Key.UP)*contacto;
}
}

Por Teseo

SWAT Team

1780 de clabLevel

14 tutoriales

Genero:Masculino   SWAT

firefox
Citar            
MensajeEscrito el 18 Nov 2007 12:34 am
muchas gracias por responder! aunque no me funciono.....

pero esta buena la alternativa a los condicionales... es mucho mas corto como lo has echo vos... una lastima que no me funcione....

no se si se les ocurre alguna forma de hacerlo... (y si es en base al codigo mio mejor)... o de alguna otra forma.

Gracias!

Por Engrampany

8 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 19 Nov 2007 07:42 pm

Código :

onClipEvent (load) {
velocidad = 7;
var personaje:MovieClip;
var pared:MovieClip;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= velocidad;
if (_root.pared.hitTest(_x, _y, true)) _x += velocidad;
}
if (Key.isDown(Key.RIGHT)) {
_x += velocidad;
if (_root.pared.hitTest(_x, _y, true)) _x -= velocidad;
}
if (Key.isDown(Key.UP)) {
_y -= velocidad;
if (_root.pared.hitTest(_x, _y, true)) _y += velocidad;
}
if (Key.isDown(Key.DOWN)) {
_y += velocidad;
if (_root.pared.hitTest(_x, _y, true)) _y -= velocidad;
}
}

Por Teseo

SWAT Team

1780 de clabLevel

14 tutoriales

Genero:Masculino   SWAT

firefox
Citar            
MensajeEscrito el 20 Nov 2007 01:35 am
me funciono a pleno ahora! =)
muchas gracias!

Por Engrampany

8 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 18 Dic 2007 06:57 am
Gracias , me sirvio tambien para el juego que estoy haciendo...

Por JC_esar

8 de clabLevel



Genero:Masculino  

opera

 

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