Doriti să reactionati la acest mesaj? Creati un cont în câteva clickuri sau conectati-vă pentru a continua.



 
AcasaUltimele imaginiCăutareÎnregistrareConectare

 

 Fulgi de zapada

In jos 
AutorMesaj
knight
Fondator
Fondator
knight


Mesaje : 192
Data de înscriere : 27/03/2008
Varsta : 30
Localizare : Undeva...Nush pe unde...Dar pe undeva :D

Fulgi de zapada Empty
MesajSubiect: Fulgi de zapada   Fulgi de zapada EmptyDum Mar 30, 2008 1:01 pm

Deschide un document flash cu dimensiunea de 300x400, fondul albastru inchis (#000022) [code]si deseneaza o mica minge alba. Eu am facut una de 10 cu 10px si i-am dat gradient catre exterior astfel incat sa se piarda in fundal. Converteste-l la Symbol, Movie Clip
Fulgi de zapada Sesu44
Click dreapta pe Movie Clipul nou creat in Library si selecteaza “Linkage”, selecteaza si Export for Actionscript si introdu textul “snow” (cu tot cu ghilimele) in textfield

Fulgi de zapada Ir6ozm

In linia 1 a radacinii timeline-ului introdu aceste 29 linii de cod:

Citat :
width = 400; // pixeli<if><endif>
height = 300; // pixeli<if><endif>
max_snowsize = 6; // pixeli<if><endif>
snowflakes = 75; // cantitatea

for (i=0;i<snowflakes;i++) {
<if>
<endif>

t = attachMovie("snow","snow"+i,i);
<if>
<endif>

t._alpha = 20+Math.random()*60;
<if>
<endif>

t._x = -(width/2)+Math.random()*(1.5*width);
<if>
<endif>

t._y = -(height/2)+Math.random()*(1.5*height);
<if>
<endif>

t._xscale = t._yscale = 50+Math.random()*(max_snowsize*10);
<if>
<endif>

t.k = 1+Math.random()*2;
<if>
<endif>

t.wind = -1.5+Math.random()*(1.4*3);
<if>
<endif>

t.onEnterFrame = mover;
<if>
<endif>

}
<if>
<endif>

function mover() {
<if>
<endif>

this._y += this.k;
<if>
<endif>

this._x += this.wind;
<if>
<endif>

if (this._y > height+10) {
<if>
<endif>

this._y = -20;
<if>
<endif>

}
<if>
<endif>

if (this._x > width+20) {
<if>
<endif>

this._x = -(width/2)+Math.random()*(1.5*width);
<if>
<endif>

this._y = -20;
<if>
<endif>

} else if (this._x < -20) {
<if>
<endif>

this._x = -(width/2)+Math.random()*(1.5*width);
<if>
<endif>

this._y = -20;
<if>
<endif>

}
<if>
<endif>

}

Testeaza animatia. Cred ca a iesit cum trebuia.

O sa detaliez putin randurile codului pentru a putea intelege cum functioneaza acest efect

Primele 4 linii sunt simple

width = 400; // pixeli<if><endif>
height = 300; // pixels<if><endif>
max_snowsize = 6; // pixeli<if><endif>
snowflakes = 75; // cantitatea
Aceste setari seteaza limitele animatiei

Sa vedem randurile care sunt responsabile pentru producerea zapezii.

for (i=0;i<snowflakes;i++) {<if><endif>
t = attachMovie("snow","snow"+i,i);<if><endif>
t._alpha = 20+Math.random()*60;<if><endif>
t._x = -(width/2)+Math.random()*(1.5*width);<if><endif>
t._y = -(height/2)+Math.random()*(1.5*height);<if><endif>
t._xscale = t._yscale = 50+Math.random()*(max_snowsize*10);<if><endif>
t.k = 1+Math.random()*2;<if><endif>
t.wind = -1.5+Math.random()*(1.4*3);<if><endif>
t.onEnterFrame = mover;<if><endif>
}
Loopul creaza o variabila temp numita ‘t’ pe care o atasam la fulgul de zapada creat. Aceasta varabila distribuie opacitate intre 20 si 80 la suta fiecarui fulg. Urmatoarele doua linii pozitioneaza fulgul intr-o pozitie intamplatoare (random). Pozitia x pune fulgul putin peste fiecare margine astfel incat cand cade o face in directia in care bate vantul. Apoi marimea fulgului. Observati linia: t._xscale = t._yscale Asta inseamna ca forma fulgului este un cerc perfect. Urmatoarele doua variabile: k este pentru viteza cu are cade fulgul. Loopurile care spun fulgului sa execute functia mover in fiecare frame. Acest loop se repeta in functie de cati fulgi s-au setat. In acest exemplu 75


function mover() {
this._y += this.k;
this._x += this.wind;
if (this._y > height+10) {
this._y = -20;
}
if (this._x > width+20) {
this._x = -(width/2)+Math.random()*(1.5*width);
this._y = -20;
} else if (this._x <20> height+10) {
this._y = -20;
}
if (this._x > width+20) {
this._x = -(width/2)+Math.random()*(1.5*width);
this._y = -20;
} else if (this._x < -20) {
this._x = -(width/2)+Math.random()*(1.5*width);
this._y = -20;
}
Sus In jos
https://funnyzone.forum-canada.com
 
Fulgi de zapada
Sus 
Pagina 1 din 1
 Subiecte similare
-
» Zapada realistica in Flash

Permisiunile acestui forum:Nu puteti raspunde la subiectele acestui forum
 :: Tutoriale Flash-
Mergi direct la: