Comunidad de diseño web y desarrollo en internet online

¿Como puedo mover un objeto aleatoriamente?

Citar            
MensajeEscrito el 15 Jun 2005 10:44 pm
Hola!
Quiero mover por el escenario un clip aleatoriamente y no se como hacerlo...
¿Alguien sabe?
Gracias

Por zumita

15 de clabLevel



 

msie
Citar            
MensajeEscrito el 15 Jun 2005 11:32 pm
crea el mc y ponle esto en codigo y listo solo cambia los 400 por los x y y qu etu quieras
saludo sbye

onClipEvent (load){
x=random(400);
y=random(400);
aceleracion=7;
}

onClipEvent (enterFrame){
this._x += (x-this._x)/aceleracion;
this._y += (y-this._y)/aceleracion;
if (Math.abs(x-this._x)<0.5 && Math.abs(y-this._y)<0.5 ) {
x=random(400);
y= random(400);
}
}

Por FeNtO

BOFH

5091 de clabLevel

18 tutoriales

1 ejemplo

  Bastard Operators From Hell

FeNtO DataCenter

clabbrowser
Citar            
MensajeEscrito el 08 May 2009 05:41 pm
una variante:

var vx=Math.random()*250;
var vy=Math.random()*250;
velocidad=50;
onEnterFrame=function(){
this.bola._x += (vx-this.bola._x)/velocidad;
this.bola._y += (vy-this.bola._y)/velocidad;
if(this.bola._x<(vx-this.bola._x)/2){velocidad-=4} else {velocidad=30};
if (Math.abs(vx-this.bola._x)<20 && Math.abs(vy-this.bola._y)<20 ) {
vx=Math.random()*250;
vy=Math.random()*250;
velocidad=50;
}
}

Por elecenge

0 de clabLevel



 

msie8

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.