Accueil > Test collisions entre objets         Avec Eanim version 7__6b

version v3

09/02/2007

Nouvelle version Eanim avec Mtasc integre.
Dans Eanim , choisir 'Projet'
et 'Programmation Mtasc. une fenêtre s'ouvre,c'est l'éditeur Mtasc

Dans l'editeur Mtasc , choisir dans le cadre haut droit "Liste Fonctions"
liste selectionnee , dans le cadre bas droit , voir la liste des fonction
Cliquer sur 'Ajouter la fonction hitTest' ( 1 fois par collision desiree )
Ici , création de 3 carrés à tester avec la boule.
Dans la fenètre du prog as , les fonctions se sont affichées , avec des erreurs dans la fenêtre
centrale en bas.(c'est normale,il y a 3 fonctions identiques)
Modifier les noms des fonctions et variables:
ex: fonction collision1.. ( collision2..)   (collision3.. )
changer les noms des variables, ou ajouter un indice:
Voir l' animation ci-dessous

Voir l'aide pour plus d'infos

Accès aux Téléchargements

dans le phi, un permanent:
//-----si CARRE rouge touche boule------
if(_root.hitest1==true) {/
/ info venant MTASC
_root.hitest1=false; /
/ RAZ de l'info Mtasc
_root.boing_t._x=_root.boule._x;
_root.boing_t._y=_root.boule._y;
gotoGroup( _root.boing_t, 2 ); /
/ affiche bulle
PlayGroup(_root.boing_t );
}
// fin if hitTest1
//-----si CARRE BLEU touche boule------
if(_root.hitest2==true) {//
info venant MTASC
_root.hitest2=false; //
RAZ de l'info Mtasc
_root.boing_t._x=_root.boule._x;
_root.boing_t._y=_root.boule._y;
gotoGroup( _root.boing_t, 2 );/
/ affiche bulle
PlayGroup(_root.boing_t );
}
// fin if hitTest2
//-----si CARRE JAUNE touche boule------

if(_root.hitest3==true) {/
/ info venant MTASC
_root.hitest3=false; //
RAZ de l'info Mtasc
_root.boing_t._x=_root.boule._x;
_root.boing_t._y=_root.boule._y;
gotoGroup( _root.boing_t, 2 );
// affiche bulle
PlayGroup(_root.boing_t );
} //
fin if hitTest3
//------- appel de la fonction mtac ------------
_root.cible1=_root.boule;//
Objet qui se deplace
_root.cible2=_root.carre; //
carre rouge
_root.cible3=_root.carre1; /
/ carre bleu
_root.cible4=_root.carre2;
// carre jaune
->test:collision1(); // appel fonction 1
->test:collision2(); // appel fonction 2
->test:collision3(); // appel fonction 3
 

// --prog  script test de collision- V1------
// --prog test de collision- V7_5d ------
class test{
/*==========Fonction collision==========*/
static
function collision1() {
var mc1:Object = new Object();
mc1 = _root.cible2;
/*------ test si collision ---------- */
if (mc1.hitTest(_root.cible1)) { /*test si carre touche 'cible x'*/
_root.hitest_text="Touche_ROUGE"; /*Affiche touche */
_root.hitest1=true; /* retourne etat collision*/
} /* fin if hitTest */
}
/*==========FIN Fonction collision======*/
/*==========Fonction collision==========*/

static
function collision2() {
var mc2:Object = new Object();
mc2 = _root.cible3;
/
*------ test si collision ---------- */
if (mc2.hitTest(_root.cible1)) {
/*test si carre touche 'cible x'*/
_root.hitest_text="Touche_BLEU"; /*Affiche touche */
_root.hitest2=true;
/* retourne etat collision*/
}
/* fin if hitTest */
} /
*==========FIN Fonction collision==========*/
/*==========Fonction collision==========*/

static
function collision3() {
var mc3:Object = new Object();
mc3 = _root.cible4;
/*------ test si collision ---------- */
if (mc3.hitTest(_root.cible1)) {
/*test si carre touche 'cible x'*/
_root.hitest_text="Touche_JAUNE";
/*Affiche touche */
_root.hitest3=true;
/* retourne etat collision*/
}
/* fin if hitTest */
}
/*==========FIN Fonction collision==========*/
}
// fin de la class