Comunidad de diseño web y desarrollo en internet online

Efecto rebote en todas las paredes

Citar            
MensajeEscrito el 08 May 2008 06:59 pm
Hola a todos,

Lo primero quería saludar a todo el foro, ya que es mi primer mensaje. Saludos!!!!

Quería pedirles ayuda para solucionar un tema que tengo pendiente. He estado buscando información sobre fisica en flash, para hacer un efecto rebote.

En resumen, lo que quiero hacer es que dentro de un cuadrado, un mc se mueva por todo el cuadrado rebotando sobre sus 4 paredes.

Alguien me puede ayudar en cuanto a la búsqueda de documentación para hacer este efecto?????

Muchas gracias de antemano.

Por feten

5 de clabLevel



Genero:Masculino  

msie7
Citar            
MensajeEscrito el 09 May 2008 06:57 pm
Crea un MC con nombre de instancia box y en el primer frame de tu archivo pones esto

Código :

Stage.align = "TL";
Stage.scaleMode = "noScale";

var box:MovieClip = box;

var vel:Number = 5;

var vel_x:Number = vel+random(5);
var vel_y:Number = vel+random(5);
box.onEnterFrame = function() {
   this._x += vel_x;
   this._y += vel_y;
   if (this._x>=Stage.width-this._width/2 || this._x<=this._width/2) {
      vel_x *= -1;
   }
   if (this._y>=Stage.height-this._height/2 || this._y<=this._height/2) {
      vel_y *= -1;
   }
}

Saludos!!!

Por vcomics

217 de clabLevel



 

Medellin - Colombia

firefox

 

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