//Contador en frame de la Escena
timer = 10;
countdown = function(){
timer--;
if(timer==0){
gotoAndStop("ganaste");
}
}
countdownInterval = setInterval(countdown,1000);
-------------------------------------------------------
//En movieclip círculo
onClipEvent (enterFrame) {
if (_root.circulo, hitTest(_root.dot))
{
_root.gotoAndStop("perdiste");
}
-------------------------------------------------------
//En movieclip dot
onClipEvent (load) {
//data you may want to change
width = 800;
height = 600;
speed = Math.round(Math.random()*2)+5;
//initial positions
x = Math.random()*width;
y = Math.random()*height;
this._x = x;
this._y = y;
x_new = Math.random()*width;
y_new = Math.random()*height;
}
onClipEvent (enterFrame) {
//x movement
if (x_new>this._x) {
sign_x = 1;
} else {
sign_x = -1;
}
dx = Math.abs(x_new-this._x);
if ((dx>speed) || (dx<-speed)) {
this._x += sign_x*speed;
} else {
x_new = Math.random()*width;
}
//y movement
if (y_new>this._y) {
sign_y = 1;
} else {
sign_y = -1;
}
dy = Math.abs(y_new-this._y);
if ((dy>speed) || (dy<-speed)) {
this._y += sign_y*speed;
} else {
y_new = Math.random()*height;
}
}
----------------------------------------------------------
*Importante
Movie clips con nombres de Instancia.
Timer con nombre de variable y texto dinámico
lunes, 3 de octubre de 2011
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario