Comunidad de diseño web y desarrollo en internet online

Ayuda con el punto de rotacion

Citar            
MensajeEscrito el 21 Jun 2011 10:45 pm
:shock: estoy haciendo un juego de carreras y lo que no se es como cambiar mediante una variable, como x e y pero para el punto de rotacion del mc que seria la pista, por favor ayuda... :fsm:

Por emirc122

13 de clabLevel



 

firefox
Citar            
MensajeEscrito el 21 Jun 2011 10:45 pm

emirc122 escribió:

:shock: estoy haciendo un juego de carreras y lo que no se es como cambiar mediante una variable, como x e y pero para el punto de rotacion del mc que seria la pista, por favor ayuda... :fsm:

Por emirc122

13 de clabLevel



 

firefox
Citar            
MensajeEscrito el 22 Jun 2011 06:26 am
Utilizas radianes investiga Math.cos y Math.sen

Código ActionScript :

radian = Math.PI/180*angle;

car.x += (speed*Math.cos(radian));
car.y += (speed*Math.sin(radian));
car.rotation =angle;   

Por MaxiiSan20

Claber

168 de clabLevel



Genero:Masculino  

Montevideo

firefox
Citar            
MensajeEscrito el 22 Jun 2011 06:58 pm
no me funciona :cry:

Por emirc122

13 de clabLevel



 

firefox
Citar            
MensajeEscrito el 24 Jun 2011 01:32 am
Eso fue un ej. no es el codigo andando aca tenes un codigo andando

Código ActionScript :


stop();


 var keyLeftPressed:Boolean;  
 var keyRightPressed:Boolean;  
 var keyUpPressed:Boolean;  
 var spaceBarPressed:Boolean; 
 
var speed = 0;
var angle =0;
var radian=1
var angle1=4
addEventListener(Event.ENTER_FRAME,inicio,false,0,true)

stage.addEventListener(KeyboardEvent.KEY_DOWN,keyPressed);  
stage.addEventListener(KeyboardEvent.KEY_UP,keyReleased);  

function inicio(e:Event):void
{
mover();

}

function mover():void
{
speedOmeetro.text=String(Math.round(speed)*2)+"Kph"   
speedOmeetro.x=car.x-cam.width/2+20
speedOmeetro.y=car.y-cam.height/2+20
cam.x=car.x
cam.y=car.y

radian = Math.PI/180*angle;

car.x += (speed*Math.cos(radian));
car.y += (speed*Math.sin(radian));
car.rotation =angle;   
   
   if (keyLeftPressed)angle1=-12
   if (keyRightPressed)angle1=12
   if (keyUpPressed)speed+=0.4
   if (!keyUpPressed)speed-=0.5;
   if(speed <=0)speed=0;if(speed >=22)speed=22;
   
   angle += angle1;
   angle1 = 0;
   

   
}
 
   
      
   function keyPressed(event:KeyboardEvent)
{     
       if (event.keyCode == Keyboard.LEFT)           keyLeftPressed = true;  
       if (event.keyCode == Keyboard.RIGHT)          keyRightPressed = true;  
       if (event.keyCode == Keyboard.UP)             keyUpPressed = true;  
       if (event.keyCode == Keyboard.SPACE)          spaceBarPressed = true;  
}  
      
    function keyReleased(event:KeyboardEvent) 
{  
        if (event.keyCode == Keyboard.LEFT)            keyLeftPressed = false;  
        if (event.keyCode == Keyboard.RIGHT)           keyRightPressed = false;  
        if (event.keyCode == Keyboard.UP)              keyUpPressed = false;  
        if (event.keyCode == Keyboard.SPACE)           spaceBarPressed = false;  
}  

Por MaxiiSan20

Claber

168 de clabLevel



Genero:Masculino  

Montevideo

firefox

 

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