11 unknown users

 Word :   Username :  
 
Bottom
Author
 Thread :

Bubbles

 
n°12095
truth
-------------------------
Profil: Top Penguin
Avatar
profil
Posted on 11-16-2008 at 08:02:26 PM  
 

More flash (actually, scripting)...

 

surprisingly, file size is just 911 bytes !

 

here:

 

SWF file

 

coding:

Code :
  1. var bb = new Array(b0,b1,b2,b3,b4,b5,b6,b7,b8); //our objects
  2. var vx = new Array(1,-1,1,1,-1,1,1,-1,1);   // their x velocity
  3. var vy = new Array(1,1,-1,-1,1,1,1,-1,-1);     // their y velocity
  4. var sp = new Array(0.6,1,1.3,1.8,1.5,0.5,1.8,0.9,1.2);  // their speed
  5. var i =0 ;
  6. this.onEnterFrame = function () {
  7. for(i=0;i<=8;i++){                             // for each of 8 objects
  8. if(bb[i]._x>240||bb[i]._x<0){vx[i] = vx[i]*-1;}// if off x range, reverse velocity
  9. if(bb[i]._y>320||bb[i]._y<0){vy[i] = vy[i]*-1;}// if off y range, reverse velocity
  10. bb[i]._x = bb[i]._x + vx[i]*sp[i];        //position changed w.r.t velocity*speed
  11. bb[i]._y = bb[i]._y + vy[i]*sp[i];
  12. bb[i]._alpha = (255/320)*(320 - bb[i]._y); //bubbles transparent towards screen bottom
  13. }
  14. }
 

here b0 - b8 are instances of bubble movie clip.
240 and 320 are dimensions at which bubbles must bounce back.


Message edited by truth on 11-16-2008 at 08:03:43 PM

---------------
Good bye friends.
answer
mood
GoogleAds
profil
Posted on 11-16-2008 at 08:02:26 PM  
 

answer
n°12108
Judicator
Profil: New Penguin
Avatar
profil
Posted on 11-18-2008 at 04:56:46 AM  
 

Ahh. I see this isn't quite choppy as the others I have seen. Nice job! I will surely follow this tutorial. Very nice.  :oui:   :great:


---------------
http://farm4.static.flickr.com/3164/3040116816_61f9e447bb_o.png
answer
n°12112
uttaresh
The Penguin Master
Profil: Penguin Pro
Avatar
profil
Posted on 11-18-2008 at 03:51:42 PM  
 

Very cool! :great:


---------------
Glomping the internet populace.
http://fc02.deviantart.com/fs48/f/2009/196/0/f/0f93b76ffd0ce94dcd8f1041c69e8b42.gif
One forum at a time.

answer

Go to:
Add a reply