WEB开发网
开发学院图形图像Flash Flash与3D编程探秘(三)- 摄像机(Camera) 阅读

Flash与3D编程探秘(三)- 摄像机(Camera)

 2008-11-12 11:47:19 来源:WEB开发网   
核心提示: //keyboardfunctionsfunctionkey_down(e:KeyboardEvent):void{if(e.keyCode==37)//leftkeymove_left=true;if(e.keyCode==39)//rightkeymove_right=true;if(

//keyboardfunctions
functionkey_down(e:KeyboardEvent):void
{
  if(e.keyCode==37)      //leftkey
    move_left=true;
  if(e.keyCode==39)      //rightkey
    move_right=true;
  if(e.keyCode==38)      //upkey
    speed_up=true;
  if(e.keyCode==40)      //downkey
    brake=true;
}
functionkey_up(e:KeyboardEvent):void
{
  if(e.keyCode==37)
    move_left=false;
  if(e.keyCode==39)
    move_right=false;
  if(e.keyCode==38)
    speed_up=false;
  if(e.keyCode==40)
    brake=false;
}
functionkeyboard_response(e:Event):void
{
  if(move_left)      
  {
    //movethecameratotheleft,rememberherethefastyougo,thefastyoursteer
    camera.x-=camera.speed_z/6;
    if(camera.x<-300)camera.x=-300;   //limityourcarsoitwon'tgoofftheroad
  }
  if(move_right)
  {
    camera.x+=camera.speed_z/6;
    if(camera.x>300)camera.x=300;    //limityourcarsoitwon'tgoofftheroad
  }
  if(speed_up)
  {
    camera.speed_z+=.2;             //accelerate
    //limitthecarspeedinarange
    if(camera.speed_z<0)camera.speed_z=0;      
    elseif(camera.speed_z>120)camera.speed_z=120;
  }
  else
  {
    camera.speed_z*=.99;            //ifyoudon'thitthethrottle,itwillstopsoon
  }
  if(brake)
  {
    camera.speed_z-=.3;            //slowdown
    if(camera.speed_z<0)camera.speed_z=0;
  }
}

上一页  2 3 4 5 6 7 8  下一页

Tags:Flash 编程 探秘

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接