jueves, 6 de octubre de 2011

Script para Shooter

/ Contador en frame de la Escena

stop();

timer = 20;
countdown = function(){
timer--;
if(timer==0){
gotoAndStop("perdiste");
}
}

var score=0

countdownInterval = setInterval(countdown,1000);
-------------------------------------------------

// Acción en Botón dentro de Movie Clip

on (press) {
play();
}

-------------------------------------------------
// Acción en Frame dentro del Movie Clip en donde termine animación

_root.score++;
if(_root.score == 10) {
_root.gotoAndStop("Ganaste");
}
this._visible=false;
stop();

------------------------------------------------

En primer Frame movie clip

acceleration = 10
newpos = function () {
ranx = Math.round((Math.random ()*550));
rany = Math.round ((Math.random ()*400));
}
newpos();
this.onEnterFrame = function() {
this._x += ((ranx-this._x)/acceleration);
this._y += ((rany-this._y)/acceleration);
if (Math.round(this._x) == ranx || Math.round(this._y) == rany) {
newpos();
}
}

No hay comentarios:

Publicar un comentario