truth ------------------------- Profil: Top Penguin | More flash (actually, scripting)... surprisingly, file size is just 911 bytes ! here: coding:
Code :
- var bb = new Array(b0,b1,b2,b3,b4,b5,b6,b7,b8); //our objects
- var vx = new Array(1,-1,1,1,-1,1,1,-1,1); // their x velocity
- var vy = new Array(1,1,-1,-1,1,1,1,-1,-1); // their y velocity
- var sp = new Array(0.6,1,1.3,1.8,1.5,0.5,1.8,0.9,1.2); // their speed
- var i =0 ;
- this.onEnterFrame = function () {
- for(i=0;i<=8;i++){ // for each of 8 objects
- if(bb[i]._x>240||bb[i]._x<0){vx[i] = vx[i]*-1;}// if off x range, reverse velocity
- if(bb[i]._y>320||bb[i]._y<0){vy[i] = vy[i]*-1;}// if off y range, reverse velocity
- bb[i]._x = bb[i]._x + vx[i]*sp[i]; //position changed w.r.t velocity*speed
- bb[i]._y = bb[i]._y + vy[i]*sp[i];
- bb[i]._alpha = (255/320)*(320 - bb[i]._y); //bubbles transparent towards screen bottom
- }
- }
| 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.
|