HitTest ?

Blacknight91titi Messages postés 1732 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 9 mars 2015 - 27 oct. 2004 à 21:13
Blacknight91titi Messages postés 1732 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 9 mars 2015 - 29 oct. 2004 à 20:54
Salut
j'ai essayer de faire un hitTest pour que dans une de mes animation un bonhome ( voir source : http://www.flashkod.com/code.aspx?id=27120 [dsl le code pour le lien marchai pa ] ) quand il arrive devant un caillou il ne puisse pas aller dessus.
Le problème est que je nome moi tout les caillou en "pierre" (la variable)
donc bin il sais pas laquelle prendre..

comment faire ?

8-) Bl@cknight91Titi :-p

6 réponses

cs_alise Messages postés 2203 Date d'inscription lundi 12 juillet 2004 Statut Membre Dernière intervention 26 janvier 2010
29 oct. 2004 à 08:12
montres ton code STP
Alise
from RunIsland
0
Blacknight91titi Messages postés 1732 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 9 mars 2015 2
29 oct. 2004 à 10:07
dsl pourle spam

onClipEvent (load) {
_root.haut.stop();
_root.bas.stop();
_root.gauche.stop();
_root.droite.stop();
}
onClipEvent (keyDown) {
if (Key.getCode() == Key.UP) {
if (this._y == 1) {
_root.haut._alpha = 100;
_root.bas._alpha = 0;
_root.gauche._alpha = 0;
_root.droite._alpha = 0;
}
if (this._y>=87.2) {
_root.haut._alpha = 100;
_root.bas._alpha = 0;
_root.gauche._alpha = 0;
_root.droite._alpha = 0;
_root.haut._x = this._x;
_root.haut._y = this._y;
_root.haut.play();
this._alpha = 0;
this._y -= 86.5;
if (_root.haut._y<=42.3) {
_root.haut._y = 345-42.3;
this._y = 345-42.3;
}
}
}
if (Key.getCode() == Key.DOWN) {
if (this._y == 259.6) {
_root.bas._alpha = 100;
_root.haut._alpha = 0;
_root.gauche._alpha = 0;
_root.droite._alpha = 0;
}
if (this._y<=289.6) {
_root.bas._alpha = 100;
_root.haut._alpha = 0;
_root.gauche._alpha = 0;
_root.droite._alpha = 0;
_root.bas._x = this._x;
_root.bas._y = this._y;
_root.bas.play();
this._alpha = 0;
this._y += 86.5;
if (_root.bas._y>=345-42.5) {
_root.bas._y = 0;
this._y = 0+42.5;
}
}
}
if (Key.getCode() == Key.LEFT) {
if (this._x == 1) {
_root.gauche._alpha = 100;
_root.droite._alpha = 0;
_root.haut._alpha = 0;
_root.bas.alpha = 0;
}
if (this._x>=68) {
_root.gauche._alpha = 100;
_root.droite._alpha = 0;
_root.haut._alpha = 0;
_root.bas._alpha = 0;
_root.gauche._x = this._x;
_root.gauche._y = this._y;
_root.gauche.play();
this._alpha = 0;
this._x -= 67.5;
if (_root.gauche._x<=0) {
_root.gauche._x = 470;
this._x = 470-67.5;
}
}
}
if (Key.getCode() == Key.RIGHT) {
if (this._x == 405.4) {
_root.droite._alpha = 100;
_root.gauche._alpha = 0;
_root.haut._alpha = 0;
_root.bas._alpha = 0;
}
if (this._x<=405.4) {
_root.droite._alpha = 100;
_root.gauche._alpha = 0;
_root.haut._alpha = 0;
_root.bas._alpha = 0;
_root.droite._x = this._x;
_root.droite._y = this._y;
_root.droite.play();
this._alpha = 0;
this._x += 67.5;
if (_root.droite._x>=470) {
_root.droite._x = 0;
this._x = 0+67.5;
}
}
}
}
onClipEvent (enterFrame) {
//	if (this.hitTest(_root.pierre)) {
//		_root.haut.stop();
//		_root.bas.stop();
//		_root.gauche.stop();
//		_root.droite.stop();
//	}
if (Key.getCode() == Key.UP) {
if (this.hitTest(_root.pierre2) || this.hitTest(_root.pierre6) || this.hitTest(_root.pierre4)) {
_root.haut.stop();
this._y += 86.5;
}
}
if (Key.getCode() == Key.DOWN) {
if (this.hitTest(_root.pierre3) || this.hitTest(_root.pierre4) || this.hitTest(_root.pierre5) || this.hitTest(_root.pierre7)) {
_root.bas.stop();
this._y -= 86.5;
}
}
if (Key.getCode() == Key.LEFT) {
if (this.hitTest(_root.pierre1) || this.hitTest(_root.pierre3) || this.hitTest(_root.pierre5) || this.hitTest(_root.pierre6) || this.hitTest(_root.pierre7) || this.hitTest(_root.pierre8) || this.hitTest(_root.pierre9)) {
_root.gauche.stop();
this._x += 67.5;
}
}
if (Key.getCode() == Key.RIGHT) {
if (this.hitTest(_root.pierre6) || this.hitTest(_root.pierre7) || this.hitTest(_root.pierre8) || this.hitTest(_root.pierre9)) {
_root.droite.stop();
this._x -= 67.5;
}
}
}


voila

8-) Bl@cknight91Titi :-p
0
cs_alise Messages postés 2203 Date d'inscription lundi 12 juillet 2004 Statut Membre Dernière intervention 26 janvier 2010
29 oct. 2004 à 15:30
Ah, je vois il y a du monde ! Mais as tu essayé d'abord sur un truc très simple pour tester hitTest, avant de te lancer dans des trucs sophistiqués.
Style :
http://reuniontic.free.fr/tut/hitTest.html
http://reuniontic.free.fr/tut/hitTest.zip

c'est un exemple tiré du magazine "Multimédia", très simple mais
qui permet de comprendre et d'apréhender la fonction HitTest

Alise
from RunIsland
0
Blacknight91titi Messages postés 1732 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 9 mars 2015 2
29 oct. 2004 à 18:12
oui j'ai compris le hitTest

j'ai essayer quelque chose de plus simple avant sa évidément
mais n'y a t'il pas quelque chose pour dire que si il rencontre tel clip (et non pa variable) alors .... ?

http://www.flashkod.com/code.aspx?id=27120

va voir sa c le code que j'avai au départ g juste rajouter des obstacle

8-) Bl@cknight91Titi :-p
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_alise Messages postés 2203 Date d'inscription lundi 12 juillet 2004 Statut Membre Dernière intervention 26 janvier 2010
29 oct. 2004 à 20:13
Ok, je vais regarder, mais pas ce soir on a 2 heures de + que vous (3 à partir de lundi) car debout depuis 4h30, alors crevé
bonne soirée
Alise
from RunIsland
0
Blacknight91titi Messages postés 1732 Date d'inscription jeudi 17 juin 2004 Statut Membre Dernière intervention 9 mars 2015 2
29 oct. 2004 à 20:54
oki oki
merci
bonne nuit
a+

8-) Bl@cknight91Titi :-p
0
Rejoignez-nous