Z
Nombre de messages : 18 Age : 31 Date d'inscription : 11/08/2006
| Sujet: [Swishmax]Une roue qui s'alume succsesivement Ven 11 Aoû - 1:46 | |
| 1 - Définissez les dimensions générales 640x480 (couleur du fond #000066). Prenez un Frame Rate égal à 50. Assurez vous que dans l'onglet Export, Mask off-stage objects soit coché. 2 - Créez un cercle tel que X=0 Y=0 W=1 H=1, point d'ancrage: Center, fond et contour blancs. 3 - Convertissez le en sprite que vous nommerez dot, Target coché. Sctipt : - Citation :
- onLoad()
{ H = int(_root._height); // hauteur scene - height W = int(_root._width); // largeur scène - width a = 200; // demi grand axe - half 1st axis b = 100; // demi petit axe - half 2nd axis n = 25; // nombre de sprites - number of sprites // 30° angle inclinaison grand axe ellipse - angle inclination 1st axis alfa = Math.PI / 6; // calcule la valeur de cos et sin une fois pour toutes // work out cos and sin only once C_alfa = Math.cos(alfa); S_alfa = Math.sin(alfa); alpha_init = 50; // transparence - transparency indice = 1; // création des sprites - creating sprites T = 2 * Math.PI; // période - period dt = T / n; // incrément 2PI/n - increment R = 1; // rayon initial - initial radius for (i=1; i <n> il faut donc passer des coordonnées mathématiques relatives x(i) , y(i) aux coordonnées absolues de la scène.
We need absolute screen coordinates -------------------------------------------------*/ ("dot"+i)._X = (W/2) + x( x0(angle) , y0(angle)); ("dot"+i)._Y = (H/2) - y( x0(angle) , y0(angle)); ("dot"+i)._alpha = alpha_init; if ( angle > (Math.PI /2) ) R-=2; else R+=2; // rayons différents pour effet 3D - different radius ("dot"+i)._xscale=("dot"+i)._yscale= R*100; } dot._visible = false; } /*------------------------------------------------------------------- point d'une ellipse rapportée à un repère cartésien classique. usual coordinates of an ellipse. -------------------------------------------------------------------*/ function x0( t ) { // compense les erreurs d'arrondis - make up for rounded errors if ( t ==(Math.PI / 2) ) return 0; return ( a * Math.cos(t) ); } function y0( t ) { if (t == 0) return 0; return ( b * Math.sin(t) ); } /*----------------------------------- ellipse inclinée d'un angle alfa ellipse inclined at alfa -----------------------------------*/ function x( xold , yold ) { return ( xold*C_alfa + yold*S_alfa ); } function y( xold , yold ) { return ( yold*C_alfa - xold*S_alfa ); } /*------------------------------------------------- 5 spots successifs ont des alpha différents 5 successive spots got different alpha -------------------------------------------------*/ onFrame (1,afterPlacedObjectEvents) { increment=0; while (increment < 5) { lequel = indice+increment; if (lequel<= n) ("dot"+lequel)._alpha = alpha_init + 10*(increment+1); increment++; } } /*-------------------------------------------------------------- on change le alpha en frame 5 mais vous pouvez en changer. we modify alpha value in frame 5, but you could take another one. ---------------------------------------------------------------*/ onFrame (5,afterPlacedObjectEvents) { ("dot"+indice)._alpha-=10; if (("dot"+indice)._alpha <alpha_init> n) indice = 1; gotoSceneAndPlay("<current>",1); } Vous pouvez modifier le script si vous le sentez. | |
|