Flash与3D编程探秘(三)- 摄像机(Camera)
2008-11-12 11:47:19 来源:WEB开发网//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;
}
}
- ››FLASH不等于运算符!=的使用实例
- ››FLASH不全等运算符!==
- ››FLASH字符串分隔符运算符
- ››FLASH% 模运算符
- ››Flash+、++、+= 加法运算符
- ››Flash, 逗号运算符
- ››flash中的-、--、-=减法运算符
- ››Flash的-Infinity 常数、.点运算符、/ 除法运算符...
- ››Flash两种注释方法/*..*/ 和// 注释行分隔符运算符...
- ››Flash的/=除法赋值运算符、=赋值运算符、== 等于运...
- ››Flash之?: 条件运算符、^ 按位 XOR 运算符、^= 按...
- ››Flash的_framesloaded代码示例
更多精彩
赞助商链接