Flash - Toques de pelota

 
Vista:

Toques de pelota

Publicado por Rincewind (2 intervenciones) el 25/06/2012 02:52:18
Hola, soy un programador novel que intenta hacer un minijuego que trate de dar golpes a una pelota (como hacer toques), un fondo fijo y sin mucha complicación (he visto alguno en publicidad y mientras cargan algunos videos). El programa que uso es el Flash CS5, y de momento he conseguido una pelota flotante y una pelota que le da un ataque epiléptico y luego para (estoy un poco desesperado) y no he encontrado demasiada ayuda. Solicito ayuda para el código o para corregir el que tengo, os lo adjunto:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.Timer;
 
pelota. x=marco.width/2;
pelota. y=marco.height/2;
var ax:Number=0;
var ay:Number=0;
var vx:Number=0;
var vy:Number=0;
var g:Number=.9;
var friccion:Number=.99;
var radio:Number=pelota.height/2;
stage.addEventListener (Event.ENTER_FRAME, Entrar_en_frame);
 
function Entrar_en_frame (e: Event): void
{
vy = vy + g;
vy = vy + ay;
vx = vx + ax;
vx=vx*friccion;
vy=vy*friccion;
pelota.x = pelota.x + vx;
pelota.y = pelota.y + vy;
if(pelota.y+radio > marco.height)
{
pelota.y=marco.height-radio;
vy=vy*-1;
}
else if(pelota.y-radio<0)
{
pelota.y=radio;
vy=vy*-1;
}
 
if(pelota.x+radio>marco.width)
{
pelota.x=marco.width-radio;
vx=vx*-1;
}
else if(pelota.x-radio<0)
{
pelota.x=radio;
vx=vx*-1;
}
}
stop();
stage.addEventListener(MouseEvent.CLICK, toque);
function toque(event:MouseEvent):void
 
{
g=1;
pelota.y=marco.height/+2;
ax=Math.random()*(-.3-.3)+.3;
 
 
}
{
if(pelota.x+radio>marco.width)
{
pelota.x=marco.width-radio;
vx=vx*-1;
}
else if(pelota.x-radio<0)
{
pelota.x=radio;
vx=vx*-1;
}
{
if (pelota.y==marco.height/.1)
g=1;
ay=0;
ax=0;
friccion=.99;
}
}

Muchísimas gracias (también me urge un poco para ponerme con otras cosas, estoy muy atrancado).
Un saludo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder