Ho poco tempo e lo script che ho non funziona...
Qualcuno può aiutarmi nel far galleggiare un mc?
Mi spiego: ho un semplice movieclip che dovrà fluttuare random lungo l'asse Y (in verticale insomma). l'oscillazione verticale dovrà essere minima e morbida. Mi date una mano?
Ho provato questo:
//Create the mosquitoes
onClipEvent (load) {
// Number of mosquitoes
num = 1;
// Speed of flight (higher=faster)
maxVel = 1;
// Set the limits of the stage
topLim = -362;
botLim = 20;
leftLim = -486;
rightLim = 0;
// Turn off the main mosquitoe
queenBug._visible = false;
// Clone the main mosquito (num) times
for (i=1; i<=num; i++) {
queenBug.duplicateMovieClip("bug"+i, i);
bug = this["bug"+i];
bug._x = random(rightLim);
bug._y = random(botLim);
}
}
// Random movement code: Modify to acheive various results
onClipEvent (enterFrame) {
for (i=1; i<=num; i++) {
bug = this["bug"+i];
// Keep bugs within horizontal bounds (leftLim and rightLim)
if (bug._x-bug._width<leftLim) {
bug.xVel = random(maxVel);
} else if (bug._x+bug._width>rightLim) {
bug.xVel = -(random(maxVel));
} else {
bug.xVel = (random(100)>50) ? random(maxVel)+1 : -(random(maxVel))-1;
}
// Keep bugs within vertical bounds (botLim and topLim)
if (bug._y-bug._height<topLim) {
bug.yVel = random(maxVel)+80;
} else if (bug._y+bug._height>botLim) {
bug.yVel = -(random(maxVel))-80;
} else {
bug.yVel = (random(100)>50) ? random(maxVel)+1 : -(random(maxVel))-1;
}
// New bug location by a few random pixels dependent on speed variable maxVel
bug.xV += bug.xVel;
bug.yV += bug.yVel;
if (bug.xV>maxVel*2) {
bug.xV = maxVel*2;
} else if (bug.xV<maxVel*-2) {
bug.xV = maxVel*-2;
}
if (bug.yV>maxVel*2) {
bug.yV = maxVel*2;
} else if (bug.yV<maxVel*-2) {
bug.yV = maxVel*-2;
}
// Set new bug location
bug._x += bug.xV;
bug._y += bug.yV;
}
}
ma onestamente a metterci le mani muoio....Grazie a tutti x l'aiuto