Comunidad de diseño web y desarrollo en internet online

Mostrar variable tipo Number en pantalla

Citar            
MensajeEscrito el 18 May 2011 10:28 am
Hola, soy nuevo en este foro, me he decidido a registrarme porque estoy haciendo un pequeño juego en AS3.

El problema es que necesito mostrar una variable de tipo Number en una caja de texto dinamica, lo que quiero hacer es un marcador donde se registre la puntuacion de mi juego.

Os dejo el codigo del juego y el error que me devuelve.


Juego:

Código ActionScript :

var izquierda:Number = 0;
var derecha:Number = stage.stageWidth
var velocidadx:Number = 10
var velocidady:Number = 10
/*var puntuacion1:Number = 0
var puntuacion2:Number = 0*/


Bola.addEventListener(Event.ENTER_FRAME, rebote)

function rebote(e:Event):void{
   
   Bola.x += velocidadx;
   Bola.y += velocidady;
   
   if((Bola.hitTestObject(Barra1)) || (Bola.hitTestObject(Barra2))) 
       
   {
      velocidadx *=-1;
   }
      
   if((Bola.hitTestObject(Limitearriba)) || (Bola.hitTestObject(Limiteabajo))) 
   
   {
      velocidady *=-1;
   }
   /*if (Bola.x <= 0)
      { 
       
      Bola.x = 259;                                 
      Bola.y = 184;
      puntuacion2 += 1;
      gotoAndPlay(2,"Juego1");
      stop();
      }
    if (Bola.x >= stage.stageWidth)
        {
       Bola.x = 259;                                 
        Bola.y = 184;
       puntuacion1 += 1
      gotoAndPlay(2,"Juego1");
      stop();
        }
*/

}

stage.addEventListener(MouseEvent.MOUSE_MOVE, mover);

function mover(event:MouseEvent):void
{
       Barra1.y = mouseY
      Barra1.y = mouseY

}

stage.addEventListener(KeyboardEvent.KEY_DOWN, mover2);

function mover2(event:KeyboardEvent):void
{
       switch (event.keyCode)
      {
      case Keyboard.W:
      Barra2.y -= 20;
      break;
   
        case Keyboard.S:
      Barra2.y += 20;
      break;
}

}
stop();


Codigo del marcador:

Código ActionScript :

var Puntuacion1:Number = 0;
var Puntuacion2:Number = 0;

stage.addEventListener(Event.ENTER_FRAME, marcador);

function marcador(e:Event):void
{

   if (Bola.x <= 0)
   {
      Bola.x = 259;
      Bola.y = 184;
      Marcador2.text = (Puntuacion2);
      Puntuacion2 +=  1;
   }



   if (Bola.x >= stage.stageWidth)
   {
      Bola.x = 259;
      Bola.y = 184;
      Marcador1.text = (Puntuacion1);
      Puntuacion1 +=  1;
   }

}


Error:

Código :

Juego1, Capa 'Marcador', Fotograma 1, Línea 13   1067: Conversión implícita de un valor de tipo Number a un tipo String no relacionado.
Juego1, Capa 'Marcador', Fotograma 1, Línea 23   1067: Conversión implícita de un valor de tipo Number a un tipo String no relacionado.


Si necesitais mas datos preguntadmelos, haber si damos con la solucion, pero tened en cuenta que soy novato.

Gracias

Por Josel567

7 de clabLevel



 

firefox
Citar            
MensajeEscrito el 18 May 2011 02:20 pm
Tienes que invocar el método toString()

Código ActionScript :

var numero:Number = 8;
cajadetexto.text = numero.toString();


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 May 2011 08:02 am
Gracias me ha servido.

Por Josel567

7 de clabLevel



 

firefox

 

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