Accueil > Tombe la neige |
version v1 |
10/12/2006 |
Instructions : RandomNumber(max_x); alph1=GetProperty( obj+i, _alpha ); SetProperty( obj+i, _alpha, alph1 ) ; sur l'écran de base: un groupe: "gouttes" et dans ce groupe un groupe par flocon les groupes flocons se nomment : flocon1 , flocon2...... dans cette démo, 20 groupes "flocons", vous pouvez en rajouter: faites un copier/coller d'un flocon et nommé le 'flocon21' etc... ensuite dans le groupe "permanent" ajustez le nombre dans les 2 boucles FOR, actuellement de 1 a 20. |
|
Fichier neige.phi , groupe
"permanent": if ( init1 != 11){ // init passage 1 seule fois init1=11; max_x=380 ; max_y = 300;//taille projet // ===== positionne les flocons au départ == for ( i=1; i <=20; i++) { // pour 20 flocons v1=RandomNumber(max_x); // flocon en X v2=RandomNumber(max_y); // flocon en Y // ---- obj="flocon"; // flocon = nom du groupe 'flocon' SetVariable(obj+i+"._x",v1); // position en X SetVariable(obj+i+"._y",v2); // position en Y } // fin boucle For _root.vitesse=5; // positionne une vitesse au départ } if(_root.vitesse>=10){ // pour ne pas aller trop vite _root.vitesse=10; // vitesse descente des flocons } // Fin if vitesse >= 10 if(_root.vitesse<=1){ // pour ne pas arreter _root.vitesse=1; // vitesse descente des flocons } // Fin if vitesse <= 1 _root.vite_text =ToString( _root.vitesse); //============================= // fais évoluer 20 flocons for ( i=1; i <=20; i++) { x=GetVariable(obj+i+"._x"); // récup axe des X y=GetVariable(obj+i+"._y"); // récup axe des X alea=RandomNumber(4);// déplace en x if (alea==1){ x=x+2} ;// si 1 ajoute 2 a droite if (alea==2){ x=x-2} ; // si 2 ajoute 2 a gauche if (alea==3){ x=x+4} ;// si 3 ajoute 4 a droite if (alea==4){ x=x-4} ; // si 4 ajoute 4 a gauche alea=RandomNumber(6);// + ou - vite y= y + ToNumber(_root.vitesse)+alea; if (y>=max_y) { // test si dépasse pas Y y=0; // sinon repositionne le flocon x=RandomNumber(max_x); // reposition X // force la transparence du flocon(x) au max SetProperty( obj+i, _alpha, 100 ); } // Fin if max //=== test Y pour démarrer l'effacement du flocon if (y>150) { // attente d'etre arrivé a 150 alph1=GetProperty( obj+i, _alpha ); // recup transparence alph1=(alph1 / 2)+16; // calcul nouvelle transparence SetProperty( obj+i, _alpha, alph1 ); // remet la nouvelle transparence } // fin if y > 150 SetVariable(obj+i+"._x",x); // position axe X SetVariable(obj+i+"._y",y); // position axe Y } // Fin boucle For |
|