Tengo tambien que ecir que este codigo me trae una serie de problemas, como que al cambiar de frame, me de error "typeerror #1009, o la funcion "stop();" no me funcione, osea la ignora.
Llevo arrastrando esos errores mucho tiempo pero como soy novato y al reproducir el juego no me lanza ningun error no se corregirlos.
Os dejo el codigo del juego propiamente, y del marcador del juego.
Juego:
Código ActionScript :
var velocidadx:Number = 15 var velocidady:Number = 15 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; } } 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; } }
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; Puntuacion2 += 1; Marcador2.text = Puntuacion2.toString(); } if (Bola.x >= stage.stageWidth) { Bola.x = 259; Bola.y = 184; Puntuacion1 += 1; Marcador1.text = Puntuacion1.toString(); } if ((Puntuacion1 == 5) || (Puntuacion2 == 5)){ gotoAndStop(2); } }
Boton de volver a empezar:
Código ActionScript :
BotonInicio.addEventListener(MouseEvent.CLICK, inicio); function inicio(event:MouseEvent):void { gotoAndPlay (1); }
Resumen: No me funciona bien el boton, no va "stop(); y da errores al cambiar de frame.