Comunidad de diseño web y desarrollo en internet online

juego en flash

Citar            
MensajeEscrito el 19 Abr 2010 12:48 pm
Buenas, estoy creando un juego en flash, actualmente he conseguido algunos resultados curiosos pero necesito mejorar el juego.
El codigo es este:

Código ActionScript :

/*--- declare variables and instances------*/
var btnStart:Button;
var mcBubble:MovieClip;
var bubbleCount:Number = 1;
var score:Number = 0;
/*--- create objects------*/
var initBubble:Object = new Object();
var sndRambo:Sound = new Sound();
sndRambo.attachSound("locooo");
/*--- handle events------*/
mcPin.onPress = function(){
}
this.startDrag(false,0,65,635,450);
mcPin.onRelease = function(){
   this.stopDrag();
}

initBubble.onEnterFrame = function(){
   this._x += this.speedX;
   this._y += this.speedY;
   this._rotation += this.rotateAngle;
   this._alpha -= 2;
   if(this._x < 65 || this._x>635){
      this.speedX *=-1;
      this.rotateAngle *=-1;
   }
   if(this._y< 80 || this._y> 375){
      this.speedY *=-1;
      this.rotateAngle *=-1;

   }
   if(this._alpha <=0){
      this.unloadMovie();
   }
   if(this.hitTest(mcPin)){
      this.unloadMovie();
      sndRambo.start();
      score++;
      txtScore.text = String(score);
   }
}

btnStart.onRelease = function() {
   for(var i = 0; i<10;i++){
   makeABubble();
   }
   score = 0;
   txtScore.text = String(score);
   mcPin._x = 350;
   mcPin.y = 410;
}

/*--- functions------*/
function makeABubble() {
   initBubble.speedX = Math.random()*20-10;
   initBubble.speedY = Math.random()*20-10;
   initBubble.rotateAngle = Math.random()*20-10;
   bubbleName = "mcBubble"+String(bubbleCount);
   bubbleDepth = this.getNextHighestDepth();
   mcBubble.duplicateMovieClip(bubbleName,bubbleDepth,initBubble);
   this[bubbleName]._x = Math.random()*550+75;
   this[bubbleName]._y = Math.random()*250+75;
   bubbleCount++;
}


En este caso estoy arrastrando un puntero sobre la escena para darle a una serie de objetos y conseguir una puntuación. Para conseguir arrastrar este movieclip he usado : mcPin.onPress = function(){
}
this.startDrag(false,0,65,635,450);

Sin embargo, deseaba mover el puntero pasando el ratón por la pantalla en vez de arrastrar , es decir, sin tener que presionar el botón del ratón.

Espero que me puedan ayudar.

Muchas gracias.

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 19 Abr 2010 12:51 pm
pongo de nuevo el codigo que no estoy seguro si lo he puesto bien...ahora si esta bien

Código ActionScript :

/*--- declare variables and instances------*/
var btnStart:Button;
var mcBubble:MovieClip;
var bubbleCount:Number = 1;
var score:Number = 0;
/*--- create objects------*/
var initBubble:Object = new Object();
var sndRambo:Sound = new Sound();
sndRambo.attachSound("locooo");
/*--- handle events------*/
mcPin.onPress = function(){
   this.startDrag(false,65,65,635,450);
}
mcPin.onRelease = function(){
   this.stopDrag();
}

initBubble.onEnterFrame = function(){
   this._x += this.speedX;
   this._y += this.speedY;
   this._rotation += this.rotateAngle;
   this._alpha -= 2;
   if(this._x < 65 || this._x>635){
      this.speedX *=-1;
      this.rotateAngle *=-1;
   }
   if(this._y< 80 || this._y> 375){
      this.speedY *=-1;
      this.rotateAngle *=-1;

   }
   if(this._alpha <=0){
      this.unloadMovie();
   }
   if(this.hitTest(mcPin)){
      this.unloadMovie();
      sndRambo.start();
      score++;
      txtScore.text = String(score);
   }
}

btnStart.onRelease = function() {
   for(var i = 0; i<10;i++){
   makeABubble();
   }
   score = 0;
   txtScore.text = String(score);
   mcPin._x = 350;
   mcPin.y = 410;
}

/*--- functions------*/
function makeABubble() {
   initBubble.speedX = Math.random()*20-10;
   initBubble.speedY = Math.random()*20-10;
   initBubble.rotateAngle = Math.random()*20-10;
   bubbleName = "mcBubble"+String(bubbleCount);
   bubbleDepth = this.getNextHighestDepth();
   mcBubble.duplicateMovieClip(bubbleName,bubbleDepth,initBubble);
   this[bubbleName]._x = Math.random()*550+75;
   this[bubbleName]._y = Math.random()*250+75;
   bubbleCount++;
}

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 19 Abr 2010 02:04 pm
Si no hay un onPress que lo dispare, mirate Mouse.onMouseMove, que chequea el movimiento del Mouse

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 19 Abr 2010 09:32 pm
mm en ello estoy creo que más o menos lo he conseguido..gracias...

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari

 

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